Browse Source

Fixed triggering callback in wrap after it was queued

master
theorm 9 years ago
parent
commit
e9c4f0af2a
  1. 3
      lib/caching.js
  2. 21
      test/caching.unit.js

3
lib/caching.js

@ -107,7 +107,8 @@ var caching = function(args) {
}
if (!self._isCacheableValue(data)) {
return cb();
callbackFiller.fill(key, null, data);
return;
}
self.store.set(key, data, options, function(err) {

21
test/caching.unit.js

@ -688,6 +688,27 @@ describe("caching", function() {
});
});
});
context("when wrapped function returns a non cacheable value once", function() {
it("second call to 'wrap' triggers the callback", function(done) {
var key = support.random.string();
// 1.
cache.wrap(key, function(cb) {
cb(null, undefined);
}, function(err, result) {
assert.equal(result, undefined);
});
// 2.
cache.wrap(key, function(cb) {
cb(null, undefined);
}, function(err, result) {
assert.equal(result, undefined);
done();
});
});
});
});
describe("when called multiple times in parallel with same key", function() {

Loading…
Cancel
Save