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 +3 -0
- package/lib/stores/memory.js +7 -8
- package/package.json +1 -1
package/History.md
CHANGED
package/lib/stores/memory.js
CHANGED
|
@@ -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 :
|
|
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,
|
|
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],
|
|
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
|
|
67
|
+
var ttl = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.ttl;
|
|
69
68
|
|
|
70
|
-
lruCache.set(key, value,
|
|
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
|
|
90
|
+
var ttl = (options.ttl || options.ttl === 0) ? options.ttl * 1000 : lruOpts.ttl;
|
|
92
91
|
|
|
93
|
-
var values = setMultipleKeys(args,
|
|
92
|
+
var values = setMultipleKeys(args, ttl);
|
|
94
93
|
|
|
95
94
|
if (cb) {
|
|
96
95
|
process.nextTick(cb.bind(null, null));
|