kitten-cache
v0.3.0
Published
Highly performant LRU cache.
Downloads
3,581
Readme
Kitten-cache
Highly performant LRU cache.
Install
- Install
npm i kitten-cache
- Require the dependence
const Cache = require('kitten-cache');
- 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