Skip to content

Commit 3151a56

Browse files
author
Bryan Donovan
committed
Merge branch 'release/4.0.1'
2 parents 5c6fe0c + 1a923ac commit 3151a56

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

History.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
- 4.0.1
2+
- Fix TTL option bug for memory cache (#194). - @anchan828
3+
14
- 4.0.0
25
- Upgrade to lru-cache 7.x (#193). - @orgads
36
- This has a breaking change in memoryCache.dump().

lib/stores/memory.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ var memoryStore = function(args) {
3030
self.usePromises = !(typeof Promise === 'undefined' || args.noPromises);
3131
self.shouldCloneBeforeSet = args.shouldCloneBeforeSet !== false; // clone by default
3232

33-
var ttl = args.ttl;
3433
var lruOpts = {
3534
max: args.max || 500,
3635
maxSize: args.maxSize,
37-
ttl: (ttl || ttl === 0) ? ttl * 1000 : null,
36+
ttl: (args.ttl || args.ttl === 0) ? args.ttl * 1000 : undefined,
3837
dispose: args.dispose,
3938
sizeCalculation: args.sizeCalculation || args.length,
4039
allowStale: args.allowStale || args.stale,
@@ -44,11 +43,11 @@ var memoryStore = function(args) {
4443

4544
var lruCache = new Lru(lruOpts);
4645

47-
var setMultipleKeys = function setMultipleKeys(keysValues, maxAge) {
46+
var setMultipleKeys = function setMultipleKeys(keysValues, ttl) {
4847
var length = keysValues.length;
4948
var values = [];
5049
for (var i = 0; i < length; i += 2) {
51-
lruCache.set(keysValues[i], keysValues[i + 1], maxAge);
50+
lruCache.set(keysValues[i], keysValues[i + 1], {ttl});
5251
values.push(keysValues[i + 1]);
5352
}
5453
return values;
@@ -65,9 +64,9 @@ var memoryStore = function(args) {
6564
}
6665
options = options || {};
6766

68-
var maxAge = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.maxAge;
67+
var ttl = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.ttl;
6968

70-
lruCache.set(key, value, maxAge);
69+
lruCache.set(key, value, {ttl});
7170
if (cb) {
7271
process.nextTick(cb.bind(null, null));
7372
} else if (self.usePromises) {
@@ -88,9 +87,9 @@ var memoryStore = function(args) {
8887
options = args.pop();
8988
}
9089

91-
var maxAge = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.maxAge;
90+
var ttl = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.ttl;
9291

93-
var values = setMultipleKeys(args, maxAge);
92+
var values = setMultipleKeys(args, ttl);
9493

9594
if (cb) {
9695
process.nextTick(cb.bind(null, null));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cache-manager",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Cache module for Node.js",
55
"main": "index.js",
66
"files": [

0 commit comments

Comments
 (0)