Browse Source

add multi_caching.reset()

master
Konstantin Pogorelov 8 years ago
parent
commit
268876a21a
  1. 14
      lib/multi_caching.js
  2. 28
      test/multi_caching.unit.js

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