From e5747bdf6275843b813ba48f493c8a97d1946ad2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Dec 2015 16:18:53 +0530 Subject: [PATCH 1/2] Additinally cache parameter added --- lib/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cache.js b/lib/cache.js index 35477ff..61b8f6b 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -34,7 +34,7 @@ exports.install = module.exports.install = function(mongoose, options, Aggregate log('cache hit: ', key); for (i = 0; i < args.length; i++) { if (typeof args[i] === 'function') { - args[i](null, obj); + args[i](null, obj, true); break; } } From cc6ec7b23749a4139660739e463db276a09421c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Dec 2015 16:34:57 +0530 Subject: [PATCH 2/2] Additinally cache parameter added - keep additional params on everywhere --- lib/cache.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/cache.js b/lib/cache.js index 61b8f6b..42f041e 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -24,7 +24,7 @@ exports.install = module.exports.install = function(mongoose, options, Aggregate var exec = function(caller, args) { if (!this.__cached) { - return orig[caller].apply(this, args); + return orig[caller].apply(this, args, false); } var key = genKey(this), obj = cache.get(key), @@ -46,7 +46,9 @@ exports.install = module.exports.install = function(mongoose, options, Aggregate log('save to cache: ', key); cache.set(key, obj); } - this.apply(this, arguments); + var t = Array.prototype.slice.call(arguments); + t.push(false); + this.apply(this, t); } for (i = 0; i < args.length; i++) { @@ -54,7 +56,7 @@ exports.install = module.exports.install = function(mongoose, options, Aggregate continue; args[i] = (cacheSet).bind(args[i]); } - return orig[caller].apply(this, args); + return orig[caller].apply(this, args, false); }; function genKey(query) {