mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-01-18 16:37:21 +01:00
Ensure to handle async events in case of promise mode
This commit is contained in:
@@ -17,7 +17,8 @@ extensions.maxAge = function (maxAge, conf, options) {
|
||||
if (!maxAge) return;
|
||||
|
||||
timeouts = create(null);
|
||||
postfix = (options.async && extensions.async) ? 'async' : '';
|
||||
postfix = ((options.async && extensions.async) || (options.promise && extensions.promise))
|
||||
? 'async' : '';
|
||||
conf.on('set' + postfix, function (id) {
|
||||
timeouts[id] = setTimeout(function () { conf.delete(id); }, maxAge);
|
||||
if (!preFetchTimeouts) return;
|
||||
|
||||
@@ -13,7 +13,8 @@ extensions.max = function (max, conf, options) {
|
||||
if (!max) return;
|
||||
|
||||
queue = lruQueue(max);
|
||||
postfix = (options.async && extensions.async) ? 'async' : '';
|
||||
postfix = ((options.async && extensions.async) || (options.promise && extensions.promise))
|
||||
? 'async' : '';
|
||||
|
||||
conf.on('set' + postfix, hit = function (id) {
|
||||
id = queue.hit(id);
|
||||
|
||||
@@ -11,7 +11,8 @@ extensions.refCounter = function (ignore, conf, options) {
|
||||
var cache, postfix;
|
||||
|
||||
cache = create(null);
|
||||
postfix = (options.async && extensions.async) ? 'async' : '';
|
||||
postfix = ((options.async && extensions.async) || (options.promise && extensions.promise))
|
||||
? 'async' : '';
|
||||
|
||||
conf.on('set' + postfix, function (id, length) { cache[id] = length || 1; });
|
||||
conf.on('get' + postfix, function (id) { ++cache[id]; });
|
||||
|
||||
Reference in New Issue
Block a user