Browse Source

Call back on set errors too.

feature/nested-cache-fetch-fix
Elliott Foster 10 years ago
parent
commit
8c82266887
  1. 30
      lib/caching.js

30
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];
});

Loading…
Cancel
Save