I've got an expiry of 15 minutes for an item and was debugging why it doesn't sometimes call onExpire. I created a test case within inspector to see what was going on and it seems removeExpired() checks for expiredItem.expires < now which should be <=.
var cache = angular.element(document.body).injector().get('DSCacheFactory')('test', {
onExpire: function() {
console.log('onExpire: ' + new Date);
}
});
cache.put('abc', 123);
cache.setRecycleFreq(2000);
cache.setMaxAge(2000);
console.log('put: ' + new Date);
The above expires either 20 or 40 seconds later depending on if there was an extra millisecond during the check.
I've got an expiry of 15 minutes for an item and was debugging why it doesn't sometimes call
onExpire
. I created a test case within inspector to see what was going on and it seemsremoveExpired()
checks forexpiredItem.expires < now
which should be<=
.The above expires either 20 or 40 seconds later depending on if there was an extra millisecond during the check.