@koeroesi86/cache
TypeScript icon, indicating that this package has built-in type declarations

21.5.5-f6599b3 • Public • Published

@koeroesi86/cache Build Status npm version

Install

yarn add @koeroesi86/cache

or

npm install --save @koeroesi86/cache

Usage example

const { InmemoryCache } = require('@koeroesi86/cache')

const initialState = {};
const expiredCallback = console.log;
const cache = new InmemoryCache(initialState, expiredCallback);

// key, value, expiry
cache.set("example", { data: "thing" }, 5000);

console.log("cached:", cache.get("example"));
declare class InmemoryCache<T = any> {
  has: (key: string) => boolean;
  get: (key: string) => T;
  set: (key: string, data: T, interval?: number) => void;
  all: () => { [key: string]: T };
  flush: () => void;
}

See full example in example/index.js

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i @koeroesi86/cache

    Weekly Downloads

    1

    Version

    21.5.5-f6599b3

    License

    MIT

    Unpacked Size

    4.21 kB

    Total Files

    6

    Last publish

    Collaborators

    • koeroesi86