Tag: lru

节点js中的LRUcaching

我需要为我的项目实施caching(对于我的组织),我们打算有一个内存LRUcaching,我有一些包,但我不知道授权条款,我发现最好的是这个 https://www.npmjs.com/package/lru-cache 但是在这里,当我声明我的caching为时,我正面临一些问题 var LRU = require("lru-cache") , options = { max: 2 , length: function (n, key) { return n * 2 + key.length } , dispose: function (key, n) { n.close() } , maxAge: 1000 * 60 * 60 } , cache = LRU(options) console.log(cache.length) cache.set(1,1) cache.set(2,2) cache.set(3,3) console.log(cache.length) console.log(cache.get(1)) console.log(cache.get(2)) console.log(cache.get(3)) console.log(cache) […]