Highly performant LRU cache.
- Install
npm i kitten-cache
- Require the dependence
const Cache = require('kitten-cache');
- Declare new instance
let cache = new Cache();
new Cache(options)
/*
options : {
size : default 50,
onRemove : function to call when a key/value is removed from the cache
}
*/
let cache = new Cache();
cache.set('a', 1);
let cache = new Cache();
cache.set('a', 1);
cache.get('a'); // -> 1
let cache = new Cache();
cache.set('a', 1);
cache.has('a'); // -> true
cache.has('b'); // -> false
let cache = new Cache();
cache.set('a', 1);
cache.delete('a'); // -> true
cache.delete('b'); // -> false