Skip to content

Commit 1f06dfd

Browse files
committed
Merge branch 'master' into develop
2 parents 5deeb89 + 427ac6a commit 1f06dfd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ app.get('/foo/bar', function(req, res) {
182182
#### Custom Stores
183183

184184
You can use your own custom store by creating one with the same API as the
185-
build-in memory stores (such as a redis or memcached store). To use your own store, you can either pass
186-
in an instance of it, or pass in the path to the module.
185+
built-in memory stores (such as a redis or memcached store). To use your own store just pass
186+
in an instance of it.
187187

188188
E.g.,
189189

lib/caching.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ var caching = function(args) {
107107
}
108108

109109
if (!self._isCacheableValue(data)) {
110-
return cb();
110+
callbackFiller.fill(key, null, data);
111+
return;
111112
}
112113

113114
self.store.set(key, data, options, function(err) {

test/caching.unit.js

+21
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,27 @@ describe("caching", function() {
688688
});
689689
});
690690
});
691+
692+
context("when wrapped function returns a non cacheable value once", function() {
693+
it("second call to 'wrap' triggers the callback", function(done) {
694+
var key = support.random.string();
695+
696+
// 1.
697+
cache.wrap(key, function(cb) {
698+
cb(null, undefined);
699+
}, function(err, result) {
700+
assert.equal(result, undefined);
701+
});
702+
703+
// 2.
704+
cache.wrap(key, function(cb) {
705+
cb(null, undefined);
706+
}, function(err, result) {
707+
assert.equal(result, undefined);
708+
done();
709+
});
710+
});
711+
});
691712
});
692713

693714
describe("when called multiple times in parallel with same key", function() {

0 commit comments

Comments
 (0)