@zudojs/cache 1.2.0 → 1.2.2
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/cache.js +3 -1
- package/dist/memory.js +4 -2
- package/package.json +4 -4
package/dist/cache.js
CHANGED
|
@@ -218,7 +218,9 @@ export class CacheService {
|
|
|
218
218
|
try {
|
|
219
219
|
const remaining = await this.store.ttl?.(fullKey);
|
|
220
220
|
return typeof remaining === "number" && Number.isFinite(remaining)
|
|
221
|
-
?
|
|
221
|
+
? remaining > 0
|
|
222
|
+
? Math.max(1, Math.floor(remaining))
|
|
223
|
+
: 0
|
|
222
224
|
: remaining;
|
|
223
225
|
}
|
|
224
226
|
catch (error) {
|
package/dist/memory.js
CHANGED
|
@@ -240,8 +240,10 @@ export class MemoryCacheAdapter {
|
|
|
240
240
|
if (entry.expiresAt === null)
|
|
241
241
|
return null;
|
|
242
242
|
// Whole milliseconds, rounded down: the monotonic clock is fractional,
|
|
243
|
-
// so a TTL of 10000 read back straight after `set` was 9999.52….
|
|
244
|
-
|
|
243
|
+
// so a TTL of 10000 read back straight after `set` was 9999.52…. A key
|
|
244
|
+
// that is still present never reports 0 (its last fraction of a
|
|
245
|
+
// millisecond reads as 1), so 0 cannot be mistaken for "expired".
|
|
246
|
+
return Math.max(1, Math.floor(entry.expiresAt - monotonicNow()));
|
|
245
247
|
}
|
|
246
248
|
async expire(key, ttl) {
|
|
247
249
|
assertValidTtl(ttl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/cache",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Caching primitives, abstractions, and adapters for the Zudojs framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"!dist/.tsbuildinfo"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@zudojs/constants": "1.1.
|
|
28
|
-
"@zudojs/errors": "1.3.
|
|
29
|
-
"@zudojs/serialization": "1.2.
|
|
27
|
+
"@zudojs/constants": "1.1.3",
|
|
28
|
+
"@zudojs/errors": "1.3.1",
|
|
29
|
+
"@zudojs/serialization": "1.2.2",
|
|
30
30
|
"@zudojs/types": "1.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|