A tiny and fast Leat Recently Used(LRU) cache, written by typescript. Supports "expire" and "hits".
$ npm install @zcorky/lru
const LRU = require('@zcorky/lru').lru;
// import LRU from '@zcorky/lru'; // ts or es6
const lru = new LRU(100);
lru.set(key, value);
lru.get(key);
// value2 will be expired after 5000ms
lru.set(key2, value2, { maxAge: 5000 });
// get key and update expired
lru.get(key2, { maxAge: 5000 });
// hits
lru.hits(); // { count, rate }
- ylru: Add "expire", "allow set empty value" extends on hashlru.
- flru: A tiny (215B) and fast Least Recently Used (LRU) cache.
MIT © Moeover