From e0c011dfcf4deeff9ea385c46f4a32e4bc4d74b7 Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Wed, 10 Sep 2014 09:18:39 -0500 Subject: [PATCH] Use call instead of apply for cached results. --- lib/caching.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/caching.js b/lib/caching.js index a0665f2..e348a4d 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -39,7 +39,7 @@ var caching = function (args) { if (err && (!self.ignoreCacheErrors)) { cb(err); } else if (result) { - cb.apply(null, result); + cb.call(cb, null, result); } else if (self.queues[key]) { self.queues[key].push(cb); } else { @@ -50,7 +50,8 @@ var caching = function (args) { if (work_args[0]) { // assume first arg is an error return cb(work_args[0]); } - self.store.set(key, work_args, function (err) { + // Subsequently assume second arg is result. + self.store.set(key, work_args[1], function (err) { if (err && (!self.ignoreCacheErrors)) { return cb(err); }