lru-cache-persist
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

lru-cache-persist

LRU cache 持久化

Installation

  • Run the following command.
npm install --save lru-cache-persist
  • Import the library.
import Cache from "lru-cache-persist";

Usage

You initialize a cache using the following.

const cache = new Cache({
  namespace: "myapp",
  policy: {
    maxEntries: 50000,
    persist: false,
  },
});

Multiple caches can be mantained in an application by instantiating caches with different namespaces.

Setting a key's value in the cache

cache.set("hello", "world");
// key 'hello' is now set to 'world' in namespace 'myapp'

Get an item in the cache

const value = cache.get("key1");
console.log(value);
// 'hello'
});

For more usage examples, see the tests.

/lru-cache-persist/

    Package Sidebar

    Install

    npm i lru-cache-persist

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    39.3 kB

    Total Files

    25

    Last publish

    Collaborators

    • jasonsmart