From 8c822668870818b95e52aabc06fc70fb6b807346 Mon Sep 17 00:00:00 2001 From: Elliott Foster Date: Thu, 18 Sep 2014 10:31:13 -0500 Subject: [PATCH] Call back on set errors too. --- lib/caching.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/caching.js b/lib/caching.js index 02b26b0..6d9abd1 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -48,27 +48,27 @@ var caching = function (args) { work(function () { var work_args = Array.prototype.slice.call(arguments, 0); if (work_args[0]) { // assume first arg is an error - if (!self.ignoreCacheErrors) { - self.queues[key].forEach(function (done) { - done.apply(null, work_args); - }); - delete self.queues[key]; - } - else { - cb(work_args[0]); - } - + self.queues[key].forEach(function (done) { + done.apply(null, work_args); + }); + delete self.queues[key]; return; } // Subsequently assume second arg is result. self.store.set(key, work_args[1], function (err) { if (err && (!self.ignoreCacheErrors)) { - return cb(err); + self.queues[key].forEach(function (done) { + done.call(null, err); + }); + } + else if (!err) { + self.queues[key].forEach(function (done) { + done.apply(null, work_args); + }); + } + else { + return; } - - self.queues[key].forEach(function (done) { - done.apply(null, work_args); - }); delete self.queues[key]; });