js-lrucache
least recently used cache implemented using ES6 and Babel
Install
Run the following command:
npm install js-lrucache
Usage
import LRUCache from 'js-lrucache';
let cache = new LRUCache(4);
cache.put('a', { value: 1 });
cache.put('b', { value: 2 });
cache.put('c', { value: 3 });
cache.put('d', { value: 4 });
console.log(cache.size());
cache.put('e', { value: 5 });
console.log(cache.size());
console.log(cache.get('a'));
cache.get('b');
cache.put('f', { value: 6 });
console.log(cache.get('b'));
console.log(cache.get('c'));
let cache2 = cache.deepCopy();
console.log(cache2.get('b'));