@nxtedition/cache 1.0.10 → 1.0.11

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/lib/index.js CHANGED
@@ -172,6 +172,8 @@ export class AsyncCache {
172
172
  this.#getQuery = null
173
173
  this.#setQuery = null
174
174
  this.#delQuery = null
175
+ this.#purgeStaleQuery = null
176
+ this.#evictQuery = null
175
177
 
176
178
  process.emitWarning(err )
177
179
  break
@@ -261,7 +263,7 @@ export class AsyncCache {
261
263
  return { value: cached.value, async: false }
262
264
  }
263
265
 
264
- if (now > cached.stale) {
266
+ if (now >= cached.stale) {
265
267
  // stale-while-revalidate has expired, purge cached value.
266
268
  this.#memory?.delete(key)
267
269
  try {
@@ -312,7 +314,9 @@ export class AsyncCache {
312
314
  return value
313
315
  },
314
316
  (err) => {
315
- this.#dedupe.delete(key)
317
+ if (this.#dedupe.get(key) === promise) {
318
+ this.#dedupe.delete(key)
319
+ }
316
320
  throw err
317
321
  },
318
322
  )
package/lib/memory.js CHANGED
@@ -86,7 +86,7 @@ export class MemoryCache {
86
86
  purgeStale(now ) {
87
87
  for (let i = this.#arr.length - 1; i >= 0; i--) {
88
88
  const entry = this.#arr[i]
89
- if (now > entry.stale) {
89
+ if (now >= entry.stale) {
90
90
  this.#delete(entry)
91
91
  }
92
92
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/cache",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -28,5 +28,5 @@
28
28
  "rimraf": "^6.1.2",
29
29
  "typescript": "^5.9.3"
30
30
  },
31
- "gitHead": "17807cefcac092e20ebf99befddf0e742e5fc0e2"
31
+ "gitHead": "80ace3245dc851f38a288b0c3b167ca0024f0469"
32
32
  }