Browse Source

Merge branch 'master' into develop

develop
Bryan Donovan 8 years ago
parent
commit
ebcd43c647
  1. 2
      History.md
  2. 2
      README.md
  3. 14
      lib/multi_caching.js
  4. 28
      test/multi_caching.unit.js

2
History.md

@ -1,5 +1,5 @@
- 2.1.2 2016-06-08
- Checking that callback array exists before iterating over it (#69).
- Checking that callback array exists before iterating over it (#57).
- 2.1.1 2016-05-24
- Fixing version number in package.json.

2
README.md

@ -41,6 +41,8 @@ See the [Express.js cache-manager example app](https://github.com/BryanDonovan/n
* [node-cache-manager-hazelcast](https://github.com/marudor/node-cache-manager-hazelcast)
* [node-cache-manager-memcached-store](https://github.com/theogravity/node-cache-manager-memcached-store)
## Overview
First, it includes a `wrap` function that lets you wrap any function in cache.

14
lib/multi_caching.js

@ -318,6 +318,20 @@ var multiCaching = function(caches, options) {
}, cb);
};
/**
* Reset all caches.
*
* @function
* @name reset
*
* @param {function} cb
*/
self.reset = function(cb) {
async.each(caches, function(cache, next) {
cache.store.reset(next);
}, cb);
};
return self;
};

28
test/multi_caching.unit.js

@ -39,7 +39,7 @@ describe("multiCaching", function() {
name = support.random.string();
});
describe("get(), set(), del()", function() {
describe("get(), set(), del(), reset()", function() {
var value;
beforeEach(function() {
@ -267,6 +267,32 @@ describe("multiCaching", function() {
});
});
});
describe("reset()", function() {
it("resets all caches", function(done) {
multiCache.set(key, value, function(err) {
checkErr(err);
multiCache.reset(function() {
memoryCache.get(key, function(err, result) {
checkErr(err);
assert.ok(!result);
memoryCache2.get(key, function(err, result) {
checkErr(err);
assert.ok(!result);
memoryCache3.get(key, function(err, result) {
checkErr(err);
assert.ok(!result);
done();
});
});
});
});
});
});
});
});
describe("getAndPassUp()", function() {

Loading…
Cancel
Save