@deepjs/cache
v0.2.9
Published
cache
Downloads
2
Readme
cache
底层为 lru-cache 独立包,功能强大,使用简单
使用
https://github.com/isaacs/node-lru-cache
import { cache, LRU } from '@deepjs/cache'
const value = {temp: 'cache'}
cache.set('key', value, 60*5*1000)
cache.set('key', value)
cache.get('key')
const options = {
max: 500,
length: function (n, key) { return n * 2 + key.length },
dispose: function (key, n) { n.close() },
maxAge: 1000 * 60 * 60,
}
const cache1 = new LRU(option);
const cache2 = new LRU(50); // sets just the max size
cache1.set('key', value)
cache1.get('key') // "value"