From 5d37dd591ef3f5827685a48609e196d7d2b8d17f Mon Sep 17 00:00:00 2001 From: Dca Date: Tue, 28 Jan 2014 16:10:56 +0800 Subject: [PATCH 1/2] Don't Cache if work error --- lib/caching.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/caching.js b/lib/caching.js index cfd203d..579cb14 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -19,9 +19,11 @@ module.exports = function Caching(store) { queues[key].push(done); } else { queues[key] = [done]; - work(function(){ + work(function(err){ var args = Array.prototype.slice.call(arguments, 0); - store.set(key, ttl, args); + if (err) { + store.set(key, ttl, args); + } queues[key].forEach(function(done){ done.apply(null, args); }); @@ -34,4 +36,4 @@ module.exports = function Caching(store) { cacher.store = store; return cacher; -}; \ No newline at end of file +}; From 34c41ff2af2430b373efd55b7840651d609edb1d Mon Sep 17 00:00:00 2001 From: Dca Date: Wed, 26 Feb 2014 14:48:54 +0800 Subject: [PATCH 2/2] Update caching.js --- lib/caching.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/caching.js b/lib/caching.js index 579cb14..087f3d8 100644 --- a/lib/caching.js +++ b/lib/caching.js @@ -21,7 +21,7 @@ module.exports = function Caching(store) { queues[key] = [done]; work(function(err){ var args = Array.prototype.slice.call(arguments, 0); - if (err) { + if (!err) { store.set(key, ttl, args); } queues[key].forEach(function(done){