cache-manager 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/History.md CHANGED
@@ -1,3 +1,6 @@
1
+ - 4.0.1
2
+ - Fix TTL option bug for memory cache (#194). - @anchan828
3
+
1
4
  - 4.0.0
2
5
  - Upgrade to lru-cache 7.x (#193). - @orgads
3
6
  - This has a breaking change in memoryCache.dump().
@@ -30,11 +30,10 @@ var memoryStore = function(args) {
30
30
  self.usePromises = !(typeof Promise === 'undefined' || args.noPromises);
31
31
  self.shouldCloneBeforeSet = args.shouldCloneBeforeSet !== false; // clone by default
32
32
 
33
- var ttl = args.ttl;
34
33
  var lruOpts = {
35
34
  max: args.max || 500,
36
35
  maxSize: args.maxSize,
37
- ttl: (ttl || ttl === 0) ? ttl * 1000 : null,
36
+ ttl: (args.ttl || args.ttl === 0) ? args.ttl * 1000 : undefined,
38
37
  dispose: args.dispose,
39
38
  sizeCalculation: args.sizeCalculation || args.length,
40
39
  allowStale: args.allowStale || args.stale,
@@ -44,11 +43,11 @@ var memoryStore = function(args) {
44
43
 
45
44
  var lruCache = new Lru(lruOpts);
46
45
 
47
- var setMultipleKeys = function setMultipleKeys(keysValues, maxAge) {
46
+ var setMultipleKeys = function setMultipleKeys(keysValues, ttl) {
48
47
  var length = keysValues.length;
49
48
  var values = [];
50
49
  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});
52
51
  values.push(keysValues[i + 1]);
53
52
  }
54
53
  return values;
@@ -65,9 +64,9 @@ var memoryStore = function(args) {
65
64
  }
66
65
  options = options || {};
67
66
 
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;
69
68
 
70
- lruCache.set(key, value, maxAge);
69
+ lruCache.set(key, value, {ttl});
71
70
  if (cb) {
72
71
  process.nextTick(cb.bind(null, null));
73
72
  } else if (self.usePromises) {
@@ -88,9 +87,9 @@ var memoryStore = function(args) {
88
87
  options = args.pop();
89
88
  }
90
89
 
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;
92
91
 
93
- var values = setMultipleKeys(args, maxAge);
92
+ var values = setMultipleKeys(args, ttl);
94
93
 
95
94
  if (cb) {
96
95
  process.nextTick(cb.bind(null, null));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Cache module for Node.js",
5
5
  "main": "index.js",
6
6
  "files": [