@nxtedition/cache 1.0.9 → 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.d.ts +1 -2
- package/lib/index.js +7 -4
- package/lib/memory.js +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type MemoryOptions } from './memory.ts';
|
|
2
|
-
export type { MemoryOptions
|
|
3
|
-
export { MemoryCache } from './memory.ts';
|
|
2
|
+
export type { MemoryOptions } from './memory.ts';
|
|
4
3
|
export interface DatabaseOptions {
|
|
5
4
|
timeout?: number;
|
|
6
5
|
maxSize?: number;
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { DatabaseSync, } from 'node:sqlite'
|
|
2
2
|
import { MemoryCache, } from "./memory.js"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export { MemoryCache } from './memory.ts'
|
|
4
|
+
|
|
6
5
|
|
|
7
6
|
let fastNowTime = 0
|
|
8
7
|
|
|
@@ -173,6 +172,8 @@ export class AsyncCache {
|
|
|
173
172
|
this.#getQuery = null
|
|
174
173
|
this.#setQuery = null
|
|
175
174
|
this.#delQuery = null
|
|
175
|
+
this.#purgeStaleQuery = null
|
|
176
|
+
this.#evictQuery = null
|
|
176
177
|
|
|
177
178
|
process.emitWarning(err )
|
|
178
179
|
break
|
|
@@ -262,7 +263,7 @@ export class AsyncCache {
|
|
|
262
263
|
return { value: cached.value, async: false }
|
|
263
264
|
}
|
|
264
265
|
|
|
265
|
-
if (now
|
|
266
|
+
if (now >= cached.stale) {
|
|
266
267
|
// stale-while-revalidate has expired, purge cached value.
|
|
267
268
|
this.#memory?.delete(key)
|
|
268
269
|
try {
|
|
@@ -313,7 +314,9 @@ export class AsyncCache {
|
|
|
313
314
|
return value
|
|
314
315
|
},
|
|
315
316
|
(err) => {
|
|
316
|
-
this.#dedupe.
|
|
317
|
+
if (this.#dedupe.get(key) === promise) {
|
|
318
|
+
this.#dedupe.delete(key)
|
|
319
|
+
}
|
|
317
320
|
throw err
|
|
318
321
|
},
|
|
319
322
|
)
|
package/lib/memory.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/cache",
|
|
3
|
-
"version": "1.0.
|
|
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": "
|
|
31
|
+
"gitHead": "80ace3245dc851f38a288b0c3b167ca0024f0469"
|
|
32
32
|
}
|