Ensure to handle async events in case of promise mode

This commit is contained in:
Mariusz Nowak
2016-07-05 17:14:24 +02:00
parent e6e98853b5
commit f9a7e38127
3 changed files with 6 additions and 3 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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]; });