Browse Source

Merge branch 'release/0.5.0'

hotfix/0.7.1 0.5.0
Bryan Donovan 11 years ago
parent
commit
1a7daed286
  1. 3
      History.md
  2. 4
      lib/caching.js
  3. 7
      lib/stores/memory.js
  4. 2
      package.json
  5. 52
      test/caching.unit.js

3
History.md

@ -1,3 +1,6 @@
- 0.5.0 2014-05-02
Adding reset() function to caching.js. Closes #5.
- 0.4.0 2014-05-02
New arg to ignore cache errors. if set cache errors will be ignored
and the cache_manager will go to the backing store. (Thanks londonjamo).

4
lib/caching.js

@ -57,6 +57,10 @@ var caching = function (args) {
self.del = self.store.del.bind(self.store);
if (typeof self.store.reset === 'function') {
self.reset = self.store.reset.bind(self.store);
}
return self;
};

7
lib/stores/memory.js

@ -32,6 +32,13 @@ var memory_store = function (args) {
}
};
self.reset = function (cb) {
lru_cache.reset();
if (cb) {
process.nextTick(cb);
}
};
return self;
};

2
package.json

@ -1,6 +1,6 @@
{
"name": "cache-manager",
"version": "0.4.0",
"version": "0.5.0",
"description": "Cache module for Node.js",
"main": "index.js",
"scripts": {

52
test/caching.unit.js

@ -1,3 +1,5 @@
// TODO: These are really a mix of unit and integration tests.
var assert = require('assert');
var sinon = require('sinon');
var support = require('./support');
@ -96,6 +98,55 @@ describe("caching", function () {
});
});
describe("reset()", function () {
var key2;
var value2;
beforeEach(function (done) {
cache = caching({store: 'memory'});
key = support.random.string(20);
value = support.random.string();
cache.set(key, value, function (err) {
check_err(err);
key2 = support.random.string(20);
value2 = support.random.string();
cache.set(key, value, done);
});
});
it("clears the cache", function (done) {
cache.reset(function (err) {
check_err(err);
cache.get(key, function (err, result) {
assert.ok(!result);
cache.get(key2, function (err, result) {
assert.ok(!result);
done();
});
});
});
});
it("lets us clear the cache without a callback", function (done) {
cache.reset();
setTimeout(function () {
cache.get(key, function (err, result) {
assert.ok(!result);
cache.get(key2, function (err, result) {
assert.ok(!result);
done();
});
});
}, 10);
});
});
describe("wrap()", function () {
describe("using memory (lru-cache) store", function () {
var memory_store_stub;
@ -282,7 +333,6 @@ describe("caching", function () {
});
});
});
});
});

Loading…
Cancel
Save