kitten-cache

0.3.0 • Public • Published

Kitten-cache

Highly performant LRU cache.

Install

  1. Install
  npm i kitten-cache
  1. Require the dependence
  const Cache = require('kitten-cache');
  1. Declare new instance
  let cache = new Cache();

API

Instance

  new Cache(options)
 
  /*
    options : {
      size     : default 50,
      onRemove : function to call when a key/value is removed from the cache
    }
  */

Cache.set(key, value)

  let cache = new Cache();
 
  cache.set('a', 1);

Cache.get(key)

  let cache = new Cache();
 
  cache.set('a', 1);
  cache.get('a'); // -> 1

Cache.has(key)

  let cache = new Cache();
 
  cache.set('a', 1);
  cache.has('a'); // -> true
  cache.has('b'); // -> false

Cache.delete(key)

  let cache = new Cache();
 
  cache.set('a', 1);
 
  cache.delete('a'); // -> true
  cache.delete('b'); // -> false

Readme

Keywords

none

Package Sidebar

Install

npm i kitten-cache

Weekly Downloads

549

Version

0.3.0

License

Apache-2.0

Unpacked Size

16.9 kB

Total Files

4

Last publish

Collaborators

  • dgrelaud
  • mrobin