This repository was archived by the owner on Apr 28, 2025. It is now read-only.
This repository was archived by the owner on Apr 28, 2025. It is now read-only.
Delete data on expiration in memory backend #32
Closed
Description
The memory backend lazily deletes expired values on get:
MemoryBackend.prototype.get = function get(key) {
var wrappedValue = this.cache[key] || null;
if (util.isExpired(wrappedValue && wrappedValue.e)) {
wrappedValue = null;
delete this.cache[key];
}
return Bluebird.resolve(wrappedValue ? wrappedValue.d : null);
};
This causes a memory leak if the data isn't accessed again, which is epecially a problem with versioned data.
Is there any interest on your end in deleting the data via timeout?
E.g.:
MemoryBackend.prototype.set = function set(key, value, options) {
this.cache[key] = {
d: value,
};
if (options.expire) {
setTimeout(this.unset.bind(this, key), options.expire * 1000);
}
return Bluebird.resolve(value);
};
I know you probably do the lazy expire for a reason. So if you're not into it, would you take a look at #31 so I we can do it from the outside?
Metadata
Metadata
Assignees
Labels
No labels