Comparing version 3.4.2 to 3.4.3
@@ -102,2 +102,7 @@ // Load modules | ||
var finalize = Hoek.once(function (id, err, value, cached, report) { | ||
return self._finalize(id, err, value, cached, report); | ||
}); | ||
if (cached && | ||
@@ -112,3 +117,3 @@ cached.isStale) { | ||
return self._finalize(id, null, cached.item, cached, report); | ||
return finalize(id, null, cached.item, cached, report); | ||
}, this.rule.staleTimeout); | ||
@@ -123,3 +128,3 @@ } | ||
return self._finalize(id, Boom.serverTimeout(), null, null, report); | ||
return finalize(id, Boom.serverTimeout(), null, null, report); | ||
}, this.rule.generateTimeout); | ||
@@ -144,7 +149,7 @@ } | ||
return self._finalize(id, err, value, null, report); // Ignored if stale value already returned | ||
return finalize(id, err, value, null, report); // Ignored if stale value already returned | ||
}); | ||
} | ||
catch (err) { | ||
this._finalize(id, err, null, null, report); | ||
return finalize(id, err, null, null, report); | ||
} | ||
@@ -157,10 +162,6 @@ }; | ||
var pendings = this._pendings[id]; | ||
if (!pendings) { | ||
return; | ||
} | ||
delete this._pendings[id]; | ||
delete this._pendings[id]; // Return only the first callback between stale timeout and generated fresh | ||
for (var i = 0, il = pendings.length; i < il; ++i) { | ||
pendings[i](err, value, cached, report); | ||
Hoek.nextTick(pendings[i])(err, value, cached, report); | ||
} | ||
@@ -167,0 +168,0 @@ }; |
{ | ||
"name": "catbox", | ||
"description": "Multi-strategy object caching service", | ||
"version": "3.4.2", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
"contributors": [ | ||
"Wyatt Preul <wpreul@gmail.com> (http://jsgeek.com)", | ||
"Ben Acker <benacker@gmail.com>" | ||
], | ||
"version": "3.4.3", | ||
"repository": "git://github.com/hapijs/catbox", | ||
@@ -16,3 +11,3 @@ "main": "index", | ||
"engines": { | ||
"node": ">=0.10.30" | ||
"node": ">=0.10.32" | ||
}, | ||
@@ -19,0 +14,0 @@ "dependencies": { |
@@ -11,3 +11,3 @@ ![catbox Logo](https://raw.github.com/hapijs/catbox/master/images/catbox.png) | ||
**catbox** is a multi-strategy key-value object store. It comes with extensions supporting a memory cache, | ||
[Redis](http://redis.io/), [MongoDB](http://www.mongodb.org/), [Memcached](http://memcached.org/), and [Riak](http://basho.com/riak/). | ||
[Redis](http://redis.io/), [MongoDB](http://www.mongodb.org/), [Memcached](http://memcached.org/), [Riak](http://basho.com/riak/) and [Amazon S3](http://aws.amazon.com/s3/). | ||
**catbox** provides two interfaces: a low-level `Client` and a high-level `Policy`. | ||
@@ -26,2 +26,3 @@ | ||
- [Riak](https://github.com/DanielBarnes/catbox-riak) | ||
- [Amazon S3](https://github.com/fhemberger/catbox-s3) | ||
@@ -28,0 +29,0 @@ |
@@ -16,4 +16,2 @@ // Load modules | ||
var expect = Lab.expect; | ||
var before = lab.before; | ||
var after = lab.after; | ||
var describe = lab.experiment; | ||
@@ -93,3 +91,3 @@ var it = lab.test; | ||
describe('#start', function () { | ||
describe('start()', function () { | ||
@@ -114,3 +112,3 @@ it('passes an error in the callback when one occurs', function (done) { | ||
describe('#get', function () { | ||
describe('get()', function () { | ||
@@ -301,3 +299,3 @@ it('returns an error when the connection is not ready', function (done) { | ||
describe('#set', function () { | ||
describe('set()', function () { | ||
@@ -327,3 +325,3 @@ it('returns an error when the connection is not ready', function (done) { | ||
describe('#drop', function () { | ||
describe('drop()', function () { | ||
@@ -330,0 +328,0 @@ it('calls the extension clients drop function', function (done) { |
@@ -17,4 +17,2 @@ // Load modules | ||
var expect = Lab.expect; | ||
var before = lab.before; | ||
var after = lab.after; | ||
var describe = lab.experiment; | ||
@@ -21,0 +19,0 @@ var it = lab.test; |
@@ -145,3 +145,3 @@ // Load modules | ||
describe('#get', function () { | ||
describe('get()', function () { | ||
@@ -797,6 +797,59 @@ it('returns cached item using object id', function (done) { | ||
}); | ||
it('does not return stale value from previous request timeout left behind', { parallel: false }, function (done) { | ||
var gen = 0; | ||
var rule = { | ||
expiresIn: 100, | ||
staleIn: 20, | ||
staleTimeout: 10, | ||
generateFunc: function (id, next) { | ||
setTimeout(function () { | ||
next(null, { gen: ++gen }); | ||
}, 5) | ||
} | ||
}; | ||
var client = new Catbox.Client(Import, { partition: 'test-partition' }); | ||
var orig = client.connection.get; | ||
client.connection.get = function (key, callback) { // Delayed get | ||
setTimeout(function () { | ||
orig.call(client.connection, key, callback) | ||
}, 10) | ||
}; | ||
var policy = new Catbox.Policy(rule, client, 'test-segment'); | ||
client.start(function () { | ||
policy.get('test', function (err, value1, cached) { // Cache lookup takes 10 + generate 5 | ||
expect(value1.gen).to.equal(1); // Fresh | ||
setTimeout(function () { // Wait for stale | ||
policy.get('test', function (err, value2, cached) { // Cache lookup takes 10, generate comes back after 5 | ||
expect(value2.gen).to.equal(2); // Fresh | ||
policy.get('test', function (err, value3, cached) { // Cache lookup takes 10 | ||
expect(value3.gen).to.equal(2); // Cached (10 left to stale) | ||
client.connection.get = orig; | ||
done() | ||
}) | ||
}); | ||
}, 21); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('#drop', function () { | ||
describe('drop()', function () { | ||
@@ -839,3 +892,3 @@ it('calls the extension clients drop function', function (done) { | ||
describe('#ttl', function () { | ||
describe('ttl()', function () { | ||
@@ -952,3 +1005,3 @@ it('returns the ttl factoring in the created time', function (done) { | ||
describe('#compile', function () { | ||
describe('compile()', function () { | ||
@@ -1349,3 +1402,3 @@ it('does not try to compile a null config', function (done) { | ||
describe('#ttl', function () { | ||
describe('ttl()', function () { | ||
@@ -1506,3 +1559,3 @@ it('returns zero when a rule is expired', function (done) { | ||
describe('#getOrGenerate', function () { | ||
describe('getOrGenerate()', function () { | ||
@@ -1509,0 +1562,0 @@ it('bypasses cache when not configured', function (done) { |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
155616
2337
131
1
2