Comparing version 0.0.2 to 0.0.3
@@ -129,2 +129,4 @@ /*! | ||
if(!entry) return; | ||
this._pullEntry(entry); | ||
@@ -131,0 +133,0 @@ delete this._cache[key]; |
@@ -5,3 +5,3 @@ { | ||
"description": "Evented in-memory cache", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -29,2 +29,43 @@ var goldfish = require('../'); | ||
}); | ||
}); | ||
describe('#expires', function() { | ||
it('should expire a value after 10ms', function(done) { | ||
var cache = goldfish.createGoldfish({ | ||
populate: function(key, cb) { | ||
cb(null, key); | ||
}, | ||
expires: 10, | ||
cleanup: 1 | ||
}); | ||
cache.on('evict', function() { | ||
done(); | ||
}); | ||
cache.get('test', function() {}); | ||
}); | ||
it('should evict multiple', function(done) { | ||
var cache | ||
, i | ||
, count = 0 | ||
, num = 200 | ||
; | ||
cache = goldfish.createGoldfish({ | ||
populate: function(key, cb) { | ||
cb(null, key); | ||
}, | ||
expires: 10, | ||
cleanup: 1 | ||
}); | ||
cache.on('evict', function() { | ||
if(++count === num) done(); | ||
}); | ||
for(i=0; i<num; ++i) { | ||
cache.get('' + i, function() {}); | ||
} | ||
}) | ||
}); |
8958
243