LRU Cache
Install with component(1):
$ component install yields/lru-cache
Initialize Cache
with opts
.max
max items.
Set key
, val
.
key
may be an object.
an optional ttl
may be given, if omitted the global ttl
is used.
var c = cache();
c.set('a', 'b', '5ms');
Get key
's value, and promote it.
Check if key
exists.
Remove key
Set max
vals and remove items if necessary.
Set ttl
for all values, you can override this at a value level.
var c = cache({ ttl: '2ms' });
c.ttl('5ms');
c.set('a', 'b', '1ms');
c.set('d', 'c'); // => 5ms
by default ttl
is 0
, which means no values will expire.
Get a cloned cache with { key: val }
structure.
Manually promote key
.
MIT