cache-manager 3.6.1 → 4.0.0

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,13 @@
1
+ - 4.0.0
2
+ - Upgrade to lru-cache 7.x (#193). - @orgads
3
+ - This has a breaking change in memoryCache.dump().
4
+
5
+ - 3.6.3 2022-05-20
6
+ - Remove import from the code in order to be able to bundle and minify the module (#191) - @ricardomozartlino
7
+
8
+ - 3.6.2 2022-05-19
9
+ - Use lodash.cloneDeep npm instead of full lodash. (#190). - @ricardomozartlino
10
+
1
11
  - 3.6.1 2022-04-07
2
12
  - Fix for potential prototype polution exploit in async < 3.2.2 (#186). - @tmbobbins
3
13
 
package/lib/caching.js CHANGED
@@ -2,8 +2,12 @@
2
2
  /*jshint maxcomplexity:16*/
3
3
  var CallbackFiller = require('./callback_filler');
4
4
  var utils = require('./utils');
5
+ var memory = require('./stores/memory.js');
6
+ var none = require('./stores/none.js');
5
7
  var parseWrapArguments = utils.parseWrapArguments;
6
8
 
9
+ var bundledStores = {memory, none};
10
+
7
11
  /**
8
12
  * Generic caching interface that wraps any caching library with a compatible interface.
9
13
  *
@@ -25,7 +29,7 @@ var caching = function(args) {
25
29
  }
26
30
  } else {
27
31
  var storeName = args.store || 'memory';
28
- self.store = require('./stores/' + storeName + '.js').create(args);
32
+ self.store = bundledStores[storeName].create(args);
29
33
  }
30
34
 
31
35
  // do we handle a cache error the same as a cache miss?
@@ -1,6 +1,6 @@
1
1
  /*eslint no-unused-vars:0*/
2
2
  var Lru = require("lru-cache");
3
- var cloneDeep = require('lodash/cloneDeep');
3
+ var cloneDeep = require('lodash.clonedeep');
4
4
  var utils = require('../utils');
5
5
  var isObject = utils.isObject;
6
6
 
@@ -33,11 +33,13 @@ var memoryStore = function(args) {
33
33
  var ttl = args.ttl;
34
34
  var lruOpts = {
35
35
  max: args.max || 500,
36
- maxAge: (ttl || ttl === 0) ? ttl * 1000 : null,
36
+ maxSize: args.maxSize,
37
+ ttl: (ttl || ttl === 0) ? ttl * 1000 : null,
37
38
  dispose: args.dispose,
38
- length: args.length,
39
- stale: args.stale,
40
- updateAgeOnGet: args.updateAgeOnGet || false
39
+ sizeCalculation: args.sizeCalculation || args.length,
40
+ allowStale: args.allowStale || args.stale,
41
+ updateAgeOnGet: args.updateAgeOnGet,
42
+ updateAgeOnHas: args.updateAgeOnHas
41
43
  };
42
44
 
43
45
  var lruCache = new Lru(lruOpts);
@@ -156,7 +158,7 @@ var memoryStore = function(args) {
156
158
  }
157
159
 
158
160
  args.forEach(function(key) {
159
- lruCache.del(key);
161
+ lruCache.delete(key);
160
162
  });
161
163
 
162
164
  if (cb) {
@@ -167,7 +169,7 @@ var memoryStore = function(args) {
167
169
  };
168
170
 
169
171
  self.reset = function(cb) {
170
- lruCache.reset();
172
+ lruCache.clear();
171
173
  if (cb) {
172
174
  process.nextTick(cb.bind(null, null));
173
175
  } else if (self.usePromises) {
@@ -176,7 +178,7 @@ var memoryStore = function(args) {
176
178
  };
177
179
 
178
180
  self.keys = function(cb) {
179
- var keys = lruCache.keys();
181
+ var keys = [...lruCache.keys()];
180
182
  if (cb) {
181
183
  process.nextTick(cb.bind(null, null, keys));
182
184
  } else if (self.usePromises) {
@@ -190,7 +192,7 @@ var memoryStore = function(args) {
190
192
  * This method is not available in the caching modules.
191
193
  */
192
194
  self.keyCount = function() {
193
- return lruCache.length;
195
+ return lruCache.size;
194
196
  };
195
197
 
196
198
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "3.6.1",
3
+ "version": "4.0.0",
4
4
  "description": "Cache module for Node.js",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -26,8 +26,8 @@
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
28
  "async": "3.2.3",
29
- "lodash": "^4.17.21",
30
- "lru-cache": "6.0.0"
29
+ "lodash.clonedeep": "^4.5.0",
30
+ "lru-cache": "^7.10.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "coveralls": "3.1.0",