cache-manager 5.7.5 → 5.7.6

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.
Files changed (2) hide show
  1. package/dist/caching.js +4 -2
  2. package/package.json +1 -1
package/dist/caching.js CHANGED
@@ -28,11 +28,13 @@ async function caching(factory, arguments_) {
28
28
  const store = factory;
29
29
  return createCache(store, arguments_);
30
30
  }
31
+ let cacheIndex = 0;
31
32
  /**
32
33
  * Create cache instance by store (non-async).
33
34
  */
34
35
  function createCache(store, arguments_) {
35
36
  const eventEmitter = new eventemitter3_1.default();
37
+ const coalescePrefix = `cache-manager-index-${cacheIndex++}`;
36
38
  return {
37
39
  /**
38
40
  * Wraps a function in cache. I.e., the first time the function is run,
@@ -47,7 +49,7 @@ function createCache(store, arguments_) {
47
49
  async wrap(key, function_, ttl, refreshThreshold, options = {}) {
48
50
  const options_ = { ...exports.defaultWrapOptions, ...options };
49
51
  const refreshThresholdConfig = refreshThreshold ?? arguments_?.refreshThreshold ?? 0;
50
- return (0, promise_coalesce_1.coalesceAsync)(key, async () => {
52
+ return (0, promise_coalesce_1.coalesceAsync)(`${coalescePrefix}:${key}`, async () => {
51
53
  const value = await store.get(key).catch(error => {
52
54
  const errorEvent = { error, key, operation: 'get' };
53
55
  eventEmitter.emit('error', errorEvent);
@@ -67,7 +69,7 @@ function createCache(store, arguments_) {
67
69
  const cacheTtl = typeof ttl === 'function' ? ttl(value) : ttl;
68
70
  const remainingTtl = await store.ttl(key);
69
71
  if (remainingTtl !== -1 && remainingTtl < refreshThresholdConfig) {
70
- (0, promise_coalesce_1.coalesceAsync)(`+++${key}`, function_)
72
+ (0, promise_coalesce_1.coalesceAsync)(`+++${coalescePrefix}:${key}`, function_)
71
73
  .then(async (result) => store.set(key, result, cacheTtl))
72
74
  .catch(async (error) => {
73
75
  const errorEvent = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "5.7.5",
3
+ "version": "5.7.6",
4
4
  "description": "Cache module for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",