Browse Source

Merge branch 'master' into develop

develop
Bryan Donovan 9 years ago
parent
commit
1f06dfd0a0
  1. 4
      README.md
  2. 3
      lib/caching.js
  3. 21
      test/caching.unit.js

4
README.md

@ -182,8 +182,8 @@ app.get('/foo/bar', function(req, res) {
#### Custom Stores #### Custom Stores
You can use your own custom store by creating one with the same API as the You can use your own custom store by creating one with the same API as the
build-in memory stores (such as a redis or memcached store). To use your own store, you can either pass built-in memory stores (such as a redis or memcached store). To use your own store just pass
in an instance of it, or pass in the path to the module. in an instance of it.
E.g., E.g.,

3
lib/caching.js

@ -107,7 +107,8 @@ var caching = function(args) {
} }
if (!self._isCacheableValue(data)) { if (!self._isCacheableValue(data)) {
return cb(); callbackFiller.fill(key, null, data);
return;
} }
self.store.set(key, data, options, function(err) { 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() { describe("when called multiple times in parallel with same key", function() {

Loading…
Cancel
Save