Added long time cache
This commit is contained in:
parent
bff7768fcb
commit
aa7396f815
|
@ -6,6 +6,7 @@
|
|||
|
||||
var LRUCache = require('mnemonist/lru-cache');
|
||||
var cache = new LRUCache(10000);
|
||||
var lingTimeCache = new LRUCache(10000);
|
||||
|
||||
module.exports = {
|
||||
set: function(hash, data, callback) {
|
||||
|
@ -19,6 +20,22 @@ module.exports = {
|
|||
? callback(null, cache.get(hash))
|
||||
: callback(null, undefined);
|
||||
},
|
||||
setSync: function(hash, data) {
|
||||
if (!process.env['NO_CACHE']) {
|
||||
cache.set(hash, data);
|
||||
}
|
||||
},
|
||||
getSync: function(hash) {
|
||||
return !process.env['NO_CACHE'] ? cache.get(hash) : undefined;
|
||||
},
|
||||
setSyncLing: function(hash, data) {
|
||||
if (!process.env['NO_CACHE']) {
|
||||
lingTimeCache.set(hash, data);
|
||||
}
|
||||
},
|
||||
getSyncLong: function(hash) {
|
||||
return !process.env['NO_CACHE'] ? lingTimeCache.get(hash) : undefined;
|
||||
},
|
||||
flush: function(callback) {
|
||||
process.env.CP_VER = process.env.CP_VER
|
||||
? parseInt(process.env.CP_VER) + 1
|
||||
|
|
Loading…
Reference in a new issue