cacheable 1.8.8 → 1.8.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/dist/index.cjs +14 -2
- package/dist/index.js +14 -2
- package/package.json +11 -10
package/dist/index.cjs
CHANGED
|
@@ -1380,8 +1380,20 @@ var Cacheable = class extends import_hookified2.Hookified {
|
|
|
1380
1380
|
const rawResult = await this._secondary.get(key, { raw: true });
|
|
1381
1381
|
if (rawResult) {
|
|
1382
1382
|
result = rawResult.value;
|
|
1383
|
-
|
|
1384
|
-
|
|
1383
|
+
let finalTtl;
|
|
1384
|
+
let expired = false;
|
|
1385
|
+
if (rawResult.expires) {
|
|
1386
|
+
const now = Date.now();
|
|
1387
|
+
finalTtl = rawResult.expires - now;
|
|
1388
|
+
if (finalTtl <= 0) {
|
|
1389
|
+
expired = true;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
if (expired) {
|
|
1393
|
+
result = void 0;
|
|
1394
|
+
} else {
|
|
1395
|
+
await this._primary.set(key, result, finalTtl);
|
|
1396
|
+
}
|
|
1385
1397
|
}
|
|
1386
1398
|
}
|
|
1387
1399
|
await this.hook("AFTER_GET" /* AFTER_GET */, { key, result });
|
package/dist/index.js
CHANGED
|
@@ -1339,8 +1339,20 @@ var Cacheable = class extends Hookified2 {
|
|
|
1339
1339
|
const rawResult = await this._secondary.get(key, { raw: true });
|
|
1340
1340
|
if (rawResult) {
|
|
1341
1341
|
result = rawResult.value;
|
|
1342
|
-
|
|
1343
|
-
|
|
1342
|
+
let finalTtl;
|
|
1343
|
+
let expired = false;
|
|
1344
|
+
if (rawResult.expires) {
|
|
1345
|
+
const now = Date.now();
|
|
1346
|
+
finalTtl = rawResult.expires - now;
|
|
1347
|
+
if (finalTtl <= 0) {
|
|
1348
|
+
expired = true;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
if (expired) {
|
|
1352
|
+
result = void 0;
|
|
1353
|
+
} else {
|
|
1354
|
+
await this._primary.set(key, result, finalTtl);
|
|
1355
|
+
}
|
|
1344
1356
|
}
|
|
1345
1357
|
}
|
|
1346
1358
|
await this.hook("AFTER_GET" /* AFTER_GET */, { key, result });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacheable",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.10",
|
|
4
4
|
"description": "High Performance Layer 1 / Layer 2 Caching with Keyv Storage",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,19 +21,20 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"private": false,
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"
|
|
24
|
+
"@faker-js/faker": "^9.6.0",
|
|
25
|
+
"@keyv/redis": "^4.3.2",
|
|
26
|
+
"@types/node": "^22.14.0",
|
|
27
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
28
|
+
"lru-cache": "^11.1.0",
|
|
28
29
|
"rimraf": "^6.0.1",
|
|
29
|
-
"tsup": "^8.
|
|
30
|
-
"typescript": "^5.
|
|
31
|
-
"vitest": "^3.
|
|
30
|
+
"tsup": "^8.4.0",
|
|
31
|
+
"typescript": "^5.8.2",
|
|
32
|
+
"vitest": "^3.1.1",
|
|
32
33
|
"xo": "^0.60.0"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"hookified": "^1.
|
|
36
|
-
"keyv": "^5.2
|
|
36
|
+
"hookified": "^1.8.1",
|
|
37
|
+
"keyv": "^5.3.2"
|
|
37
38
|
},
|
|
38
39
|
"keywords": [
|
|
39
40
|
"cacheable",
|