@nxtedition/lib 23.9.9 → 23.9.10
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/cache.js +11 -2
- package/package.json +1 -1
package/cache.js
CHANGED
|
@@ -77,12 +77,11 @@ export class AsyncCache {
|
|
|
77
77
|
if (!promise) {
|
|
78
78
|
promise = this.#valueSelector(...args).then(
|
|
79
79
|
(value) => {
|
|
80
|
-
this.#dedupe.delete(key)
|
|
81
80
|
this.set(key, value)
|
|
82
81
|
return [null, value]
|
|
83
82
|
},
|
|
84
83
|
(err) => {
|
|
85
|
-
this
|
|
84
|
+
this.delete(key)
|
|
86
85
|
return [err, null]
|
|
87
86
|
},
|
|
88
87
|
)
|
|
@@ -114,6 +113,16 @@ export class AsyncCache {
|
|
|
114
113
|
}
|
|
115
114
|
|
|
116
115
|
this.#lru.set(key, cached)
|
|
116
|
+
this.#dedupe.delete(key)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
delete(key) {
|
|
120
|
+
if (typeof key !== 'string' || key.length === 0) {
|
|
121
|
+
throw new TypeError('key must be a non-empty string')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.#lru.delete(key)
|
|
125
|
+
this.#dedupe.delete(key)
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
clear() {
|