@nxtedition/cache 2.1.3 → 2.1.5
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 +7 -5
- package/lib/memory.js +4 -0
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -425,6 +425,13 @@ export class Cache extends EventEmi
|
|
|
425
425
|
return { value: cached?.value, async: false }
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
{
|
|
429
|
+
const pending = this.#dedupe.get(key)
|
|
430
|
+
if (pending !== undefined) {
|
|
431
|
+
return { async: true, value: pending }
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
428
435
|
let result
|
|
429
436
|
try {
|
|
430
437
|
result = this.#refresh(args, key)
|
|
@@ -448,11 +455,6 @@ export class Cache extends EventEmi
|
|
|
448
455
|
throw new TypeError('keySelector must return a non-empty string')
|
|
449
456
|
}
|
|
450
457
|
|
|
451
|
-
const existing = this.#dedupe.get(key)
|
|
452
|
-
if (existing !== undefined) {
|
|
453
|
-
return { async: true, value: existing }
|
|
454
|
-
}
|
|
455
|
-
|
|
456
458
|
if (this.#lockTimeout >= 0) {
|
|
457
459
|
// Another process holds the lock — wait for the value instead of calling valueSelector.
|
|
458
460
|
// Use deferred pattern so #waitForValue can check promise identity to detect delete+get races.
|
package/lib/memory.js
CHANGED
|
@@ -121,6 +121,10 @@ export class MemoryCache {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
#prune() {
|
|
124
|
+
if (this.#cork > 0) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
124
128
|
while (this.#arr.length > 0 && (this.#size > this.#maxSize || this.#count > this.#maxCount)) {
|
|
125
129
|
const e1 = this.#arr[(Math.random() * this.#arr.length) | 0]
|
|
126
130
|
const e2 = this.#arr[(Math.random() * this.#arr.length) | 0]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/cache",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"tsd": "^0.33.0",
|
|
31
31
|
"typescript": "^5.9.3"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "8a59edc35cba6e3bdf43e82710a7cdbf413dc19c"
|
|
34
34
|
}
|