Skip to contentpackage
lrucache
v0.1.0LRU Cache in node/browser.
node any0 depscjsopen source
- license
- Unknown
- deps
- 0
- unpacked
- Unknown
- files
- Unknown
- node
- any
$npm install lrucache@0.1.0 README
GitHub-flavored package documentation.
downloads
Across all versions, last 30 days.
33,550weekly-19.8%
135,455 in 30 days
Oct 16 → Nov 14hover or arrows
compatibility
Runtime metadata.
keywords
Tagged topics.
lrucachelru-cachelrucache
versions
Latest published Jul 5, 2017
maintainers
Registry package owners.
contents
LRUCache
LRU Cache for node.js/browser.

使用链表实现的 LRU 缓存。get、set 和 update 方法会更新 LRU 优先级。
Install
Node.js:
npm install lrucache
bower install lrucache
<script src="/pathTo/lrucache.js"></script>
API
const LRUCache = require('lrucache')
Class LRUCache([capacity])
capacity: : Optional, Type: Number, Default: Number.MAX_SAFE_INTEGER.
const cache = LRUCache(100)
LRUCache.prototype.get(key)
let a = cache.get('a')
LRUCache.prototype.set(key, value)
cache.set('a', [1, 2, 3])
LRUCache.prototype.update(key, fn)
Return this, It only run when key exists.
cache.update('a', function (a) {
a.push(4)
return a
})
LRUCache.prototype.remove(key)
LRUCache.prototype.removeAll(key)
LRUCache.prototype.keys()
LRUCache.prototype.has(key)
LRUCache.prototype.staleKey()
Return the stalest key or null.
let staleKey = cache.staleKey()
LRUCache.prototype.popStale()
Return the stalest data or null.
let staleDate = cache.popStale()
LRUCache.prototype.info()