Browse Source

Merge branch 'master' into develop

feature/nested-cache-fetch-fix
Bryan Donovan 11 years ago
parent
commit
1b8e496b26
  1. 19
      lib/caching.js

19
lib/caching.js

@ -48,17 +48,24 @@ var caching = function (args) {
work(function () { work(function () {
var work_args = Array.prototype.slice.call(arguments, 0); var work_args = Array.prototype.slice.call(arguments, 0);
if (work_args[0]) { // assume first arg is an error if (work_args[0]) { // assume first arg is an error
return cb(work_args[0]); self.queues[key].forEach(function (done) {
done.call(null, work_args[0]);
});
delete self.queues[key];
return;
} }
// Subsequently assume second arg is result. // Subsequently assume second arg is result.
self.store.set(key, work_args[1], function (err) { self.store.set(key, work_args[1], function (err) {
if (err && (!self.ignoreCacheErrors)) { if (err && (!self.ignoreCacheErrors)) {
return cb(err); self.queues[key].forEach(function (done) {
done.call(null, err);
});
}
else {
self.queues[key].forEach(function (done) {
done.apply(null, work_args);
});
} }
self.queues[key].forEach(function (done) {
done.apply(null, work_args);
});
delete self.queues[key]; delete self.queues[key];
}); });

Loading…
Cancel
Save