akv-cache
Asynchronous in-memory key-value cache.
Installation
npm install akv-cache
Usage
var cache = require('akv-cache')({
ttl: 10,
grace: 60,
emptyValue: undefined,
miss: function(key, callback) {
setTimeout(function() {
callback(null, 'Data is here!');
}, 1000);
}
});
get(key, [scope], [callback]): mixed
cache.get('some-key', function(err, value) {
if (err) return console.error(err);
console.log('Got value: ' + value);
});
var value = cache.get('some-key');
cache.get('key', { data: 123 }, function(err, value) { });
set(key, value, [ttl]): akv-cache
cache.set('key1', 'some value');
cache
.set('key2', 'other value')
.set('key3', 'third value', 15);
has(key): boolean
var keyExists = cache.has('some-key');
size(): integer
var cacheSize = cache.size();
License
MIT