Browse Source

Merge branch 'release/0.13.0'

feature/nested-cache-fetch-fix 0.13.0
Bryan Donovan 10 years ago
parent
commit
1d352ed6ef
  1. 3
      History.md
  2. 2
      package.json
  3. 36
      test/multi_caching.unit.js

3
History.md

@ -1,3 +1,6 @@
- 0.13.0 2014-10-14
Applied work function locking for multi_caching (#13). -aletorrado
- 0.12.0 2014-10-09
Checking for existence of del() method before binding to it. Fixes #11.

2
package.json

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

36
test/multi_caching.unit.js

@ -1,4 +1,5 @@
var assert = require('assert');
var async = require('async');
var sinon = require('sinon');
var support = require('./support');
var check_err = support.check_err;
@ -438,6 +439,41 @@ describe("multi_caching", function () {
});
});
});
describe("when called multiple times in parallel with same key", function () {
var construct;
beforeEach(function () {
multi_cache = multi_caching([memory_cache, memory_cache3]);
construct = sinon.spy(function (val, cb) {
var timeout = support.random.number(100);
setTimeout(function () {
cb(null, 'value');
}, timeout);
});
});
it("calls the wrapped function once", function (done) {
var values = [];
for (var i = 0; i < 5; i++) {
values.push(i);
}
async.each(values, function (val, async_cb) {
multi_cache.wrap('key', function (cb) {
construct(val, cb);
}, function (err, result) {
assert.equal(result, 'value');
async_cb(err);
});
}, function (err) {
check_err(err);
assert.equal(construct.callCount, 1);
done();
});
});
});
});
context("when instantiated with a non-Array 'caches' arg", function () {

Loading…
Cancel
Save