cache-manager 6.2.0 → 6.3.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/README.md CHANGED
@@ -167,6 +167,9 @@ const cache = createCache({ stores: [keyv] });
167
167
  - **refreshThreshold**?: number - Default refreshThreshold in milliseconds.
168
168
 
169
169
  If the remaining TTL is less than **refreshThreshold**, the system will update the value asynchronously in background.
170
+ - **refreshAllStores**?: boolean - Default false
171
+
172
+ If set to true, the system will update the value of all stores when the refreshThreshold is met. Otherwise, it will only update from the top to the store that triggered the refresh.
170
173
 
171
174
  - **nonBlocking**?: boolean - Default false
172
175
 
package/dist/index.cjs CHANGED
@@ -302,7 +302,7 @@ var createCache = (options) => {
302
302
  if (shouldRefresh) {
303
303
  coalesceAsync(`+++${key}`, fnc).then(async (result) => {
304
304
  try {
305
- await set(stores.slice(0, i + 1), key, result, ms);
305
+ await set(options?.refreshAllStores ? stores : stores.slice(0, i + 1), key, result, ms);
306
306
  eventEmitter.emit("refresh", { key, value: result });
307
307
  } catch (error) {
308
308
  eventEmitter.emit("refresh", { key, value, error });
package/dist/index.d.cts CHANGED
@@ -36,6 +36,7 @@ type CreateCacheOptions = {
36
36
  stores?: Keyv[];
37
37
  ttl?: number;
38
38
  refreshThreshold?: number;
39
+ refreshAllStores?: boolean;
39
40
  nonBlocking?: boolean;
40
41
  };
41
42
  type Events = {
package/dist/index.d.ts CHANGED
@@ -36,6 +36,7 @@ type CreateCacheOptions = {
36
36
  stores?: Keyv[];
37
37
  ttl?: number;
38
38
  refreshThreshold?: number;
39
+ refreshAllStores?: boolean;
39
40
  nonBlocking?: boolean;
40
41
  };
41
42
  type Events = {
package/dist/index.js CHANGED
@@ -267,7 +267,7 @@ var createCache = (options) => {
267
267
  if (shouldRefresh) {
268
268
  coalesceAsync(`+++${key}`, fnc).then(async (result) => {
269
269
  try {
270
- await set(stores.slice(0, i + 1), key, result, ms);
270
+ await set(options?.refreshAllStores ? stores : stores.slice(0, i + 1), key, result, ms);
271
271
  eventEmitter.emit("refresh", { key, value: result });
272
272
  } catch (error) {
273
273
  eventEmitter.emit("refresh", { key, value, error });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Cache Manager for Node.js",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",