npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

quicache

v3.0.0

Published

A simple key-value cache for Javascript applications

Readme

quiCache

An in-memory key-value cache for Javascript and Typescript applications

Install

Yarn

yarn add quiCache

NPM

npm i --save quiCache

Introduction

QuiCache is an in-memory caching solution for Javascript and Typescript applications. It relies only on the date-fns package, meaning that it should be compatible with every major JS environment out there.

QuiCache provides a key-value structure for data to be stored in. When adding data to the cache, you specify the key, and the data as arguments to setCacheData(), and quiCache handles everything else. When reading data from the cache, simply provide the key to getCacheData().

API / Documentation

See the docs folder for full details. Usage examples can be found at the bottom of the readme.

Version 3.0

Version 3 now provides support for Typescript generics.

This means that data returned from the following methods will infer type data:

  • onCacheDataAdd
  • onCacheDataAccessed
  • onCacheDataDelete
  • onCacheDataExpired
  • onCacheDataAlreadyExists
  • getCacheData
  • setCacheData
  • getAllCachedData
  • deleteCacheData

Due to this, when creating a cache instance with new QuiCache(), you must also define the data type you're returning if you're fully typing it:

interface IMyDataInterface {
  aString: string;
  aNumber: number;
  aBoolean: boolean;
}

const MyCache: ICacheManager<IMyDataInterface> = new QuiCache({
  cacheName: "MyCache",
  cacheMaxAgeInSeconds: 30
});

You can still create and manage your cache in the same way if you're not specifying the type ICacheManager, but type data may not be returned.

This change doesn't prevent your ability to store data of any type in an individual cache field, but merely enhances the developer experience if you use 1 cache for data which follows a specific interface.

No other changes beyond those in 2.0 are required to be compatible with QuiCache 3.0.

Version 2.0

Version 2 has completely overhauled the library, and is mostly incompatible with prior versions (due to changes to the constructor method and several methods being removed).

The changes made should drastically simplify working with the library and provide a nicer developer experience.

  • A new method, deleteCacheData(), has been added to allow deletion of any cached data by providing it's field name / key
  • The concept of expired and non-expired data no longer exists - Cache data now automatically deletes when it expires
  • New optional callbacks in the constructor method have been aded: onCacheDataAdd, onCacheDataDelete, onCacheDataExpired, onCacheDataAlreadyExists
  • Version 2.1.2 has added some new optional callback:
    • onCacheDataAccessed - this will trigger when a field is accessed in the cache
    • onCacheDataDoesNotAlreadyExist - this will trigger if the specified field is not found in the cache when calling setCacheData, deleteCacheData
  • Enabling and disabling debug has been removed due to addition of callbacks
  • You can now provide a name to your cache, which can be useful for the callbacks
  • Methods to allow changing the cache age and name have been added
  • As of version 2.0.2 map is now used for storing data (instead of an object), meaning it is possible to set keys/fields of any type (instead of just string)
    • At this time, only strings and numbers are accepted as keys, but supporting all primitive types is planned for a future release

Further notes on version 2.0

  • The constructor now expects an object with params/arguments
  • You can only specify a cache maximum age value in seconds (e.g. 120 = 2 minutes), and it is no longer possible to specify the unit of time
  • If a key already exists in the cache, it's data will not be overwritten when calling setCacheData()
  • It is possible to update the cache max age after creation by calling setCacheMaxAge() and passing a value
    • Values which were added to the cache before this method is called are not affected and will be removed at the end of the originally intended expiry time

Interfaces

The following interfaces and enums are exported from quicache to assist in development;

ICacheManagerDataCache
ICacheManager

Example

import quicache, { ICacheManager } from "quicache";

// Create an interface for your data
interface IMyInterface {
  aString: string;
  aBoolean: boolean;
  aNumber: number;
  anOptionalString?: string;
}

// Initialize the cache with your interface
const myCache: ICacheManager<IMyInterface> = new quicache({
  cacheName: "MyCache",
  cacheMaxAgeInSeconds: 30,
  onCacheDataExpired: (data) =>
    console.log(`Field ${data.field} expired in cache ${data.cacheName}`),
  onCacheDataAdd: (data) =>
    console.log(`Field ${data.field} added to cache ${data.cacheName}`),
  onCacheDataAlreadyExists: (data) => {
    console.log(
      `Field ${data.field} already exists in cache ${data.cacheName}, and expires in ${data.expires} seconds`
    );
  },
});

const cacheKey = "testData";

// If the data doesn't exist in the cache, we'll create it
if (!myCache.cacheDataExists(cacheKey)) {
  try {
    const dataToSetInCache = {
      aString: "ABC",
      aBoolean: true,
      aNumber: 123,
    };

    // setCacheData returns the timestamp and data that it inserts into the cache
    return myCache.setCacheData(cacheKey, dataToSetInCache).data;
  } catch (err) {
    return err;
  }
} else {
  // Data exists in cache, so we'll return it
  // getCacheData returns the timestamp and data
  const cachedata = myCache.getCacheData(cacheKey);
  return cachedata.data;
}

Author(s)

👤 Scott Pritchard (Github, Twitter)