Least Recently Used cache for browser or Node.js.
npm install @doclify/lru-cache
import LRU from '@doclify/lru-cache'
// commonjs
// const LRU = require('@doclify/lru-cache')
const cache = new LRU({
max: 1000, //max items in cache
ttl: 60 * 1000 //max ttl in ms, set 0 for never expiring cache
})
cache.set('foo', 'baz')
const value = cache.get('foo')
Returns whether key exists in cache
Clears the cache
Sets item in cache
Returns item from cache
Removes item from cache
Evicts the least recently used item from cache
This repository is published under the MIT license.