@trieb.work/nextjs-turbo-redis-cache 1.8.0-beta.5 → 1.8.0
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/CHANGELOG.md +24 -0
- package/README.md +17 -17
- package/dist/index.d.mts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +19 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/RedisStringsHandler.ts +24 -38
- package/src/SyncedMap.ts +3 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
# [1.8.0](https://github.com/trieb-work/nextjs-turbo-redis-cache/compare/v1.7.1...v1.8.0) (2025-06-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improve logs ([92508b6](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/92508b6697c87cad4a8720fb5380f41fe9ec2257))
|
|
7
|
+
* remove connect timeout ([4dceda1](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/4dceda15a0ae8ca3c5fcdddf861263ef7ca237ce))
|
|
8
|
+
* scan+hscan logging ([56c82c3](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/56c82c3dd62257e8686fedc25dea45a0b7fec18e))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add redis commands debug logging ([4c8a0d7](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/4c8a0d7f82573bbaab63bdd380063244c641735f))
|
|
14
|
+
* improve error handling ([dd591da](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/dd591daab9539e6ba96da1d1c493a1e771ba272d))
|
|
15
|
+
* performance and stability improvements ([69c2b90](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/69c2b9035a526407f8dd5a73104be1132281aa2a))
|
|
16
|
+
* remove general timeoutMs and replace it with getTimeoutMs (for faster non-blocking rendering) ([02deb64](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/02deb649fce40085495c6fec5e8750cba42d2428))
|
|
17
|
+
|
|
18
|
+
# [1.8.0-beta.6](https://github.com/trieb-work/nextjs-turbo-redis-cache/compare/v1.8.0-beta.5...v1.8.0-beta.6) (2025-06-13)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* remove general timeoutMs and replace it with getTimeoutMs (for faster non-blocking rendering) ([02deb64](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/02deb649fce40085495c6fec5e8750cba42d2428))
|
|
24
|
+
|
|
1
25
|
# [1.8.0-beta.5](https://github.com/trieb-work/nextjs-turbo-redis-cache/compare/v1.8.0-beta.4...v1.8.0-beta.5) (2025-06-12)
|
|
2
26
|
|
|
3
27
|
|
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ There exists also the SKIP_KEYSPACE_CONFIG_CHECK environment variable to skip th
|
|
|
52
52
|
|
|
53
53
|
KILL_CONTAINER_ON_ERROR_THRESHOLD: Optional environment variable that defines how many Redis client errors should occur before the process exits with code 1. This is useful in container environments like Kubernetes where you want the container to restart if Redis connectivity issues persist. Set to 0 (default) to disable this feature. For example, setting KILL_CONTAINER_ON_ERROR_THRESHOLD=10 will exit the process after 10 Redis client errors, allowing the container orchestrator to restart the container.
|
|
54
54
|
|
|
55
|
-
REDIS_COMMAND_TIMEOUT_MS: Optional environment variable that sets the timeout in milliseconds for Redis
|
|
55
|
+
REDIS_COMMAND_TIMEOUT_MS: Optional environment variable that sets the timeout in milliseconds for Redis get command. If not set, defaults to 500ms. The value is parsed as an integer, and if parsing fails, falls back to the 500ms default.
|
|
56
56
|
|
|
57
57
|
### Option A: minimum implementation with default options
|
|
58
58
|
|
|
@@ -123,22 +123,22 @@ A working example of above can be found in the `test/integration/next-app-custom
|
|
|
123
123
|
|
|
124
124
|
## Available Options
|
|
125
125
|
|
|
126
|
-
| Option | Description
|
|
127
|
-
| ----------------------------- |
|
|
128
|
-
| redisUrl | Redis connection url
|
|
129
|
-
| database | Redis database number to use. Uses DB 0 for production, DB 1 otherwise
|
|
130
|
-
| keyPrefix | Prefix added to all Redis keys
|
|
131
|
-
| sharedTagsKey | Key used to store shared tags hash map in Redis
|
|
132
|
-
|
|
|
133
|
-
| revalidateTagQuerySize | Number of entries to query in one batch during full sync of shared tags hash map
|
|
134
|
-
| avgResyncIntervalMs | Average interval in milliseconds between tag map full re-syncs
|
|
135
|
-
| redisGetDeduplication | Enable deduplication of Redis get requests via internal in-memory cache.
|
|
136
|
-
| inMemoryCachingTime | Time in milliseconds to cache Redis get results in memory. Set this to 0 to disable in-memory caching completely.
|
|
137
|
-
| defaultStaleAge | Default stale age in seconds for cached items
|
|
138
|
-
| estimateExpireAge | Function to calculate expire age (redis TTL value) from stale age
|
|
139
|
-
| socketOptions | Redis client socket options for TLS/SSL configuration (e.g., `{ tls: true, rejectUnauthorized: false }`)
|
|
140
|
-
| clientOptions | Additional Redis client options (e.g., username, password)
|
|
141
|
-
| killContainerOnErrorThreshold | Number of consecutive errors before the container is killed. Set to 0 to disable.
|
|
126
|
+
| Option | Description | Default Value |
|
|
127
|
+
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| redisUrl | Redis connection url | `process.env.REDIS_URL? process.env.REDIS_URL : process.env.REDISHOST ? redis://${process.env.REDISHOST}:${process.env.REDISPORT} : 'redis://localhost:6379'` |
|
|
129
|
+
| database | Redis database number to use. Uses DB 0 for production, DB 1 otherwise | `process.env.VERCEL_ENV === 'production' ? 0 : 1` |
|
|
130
|
+
| keyPrefix | Prefix added to all Redis keys | `process.env.VERCEL_URL \|\| 'UNDEFINED_URL_'` |
|
|
131
|
+
| sharedTagsKey | Key used to store shared tags hash map in Redis | `'__sharedTags__'` |
|
|
132
|
+
| getTimeoutMs | Timeout in milliseconds for time critical Redis operations. If Redis get is not fulfilled within this time, returns null to avoid blocking site rendering. | `process.env.REDIS_COMMAND_TIMEOUT_MS ? (Number.parseInt(process.env.REDIS_COMMAND_TIMEOUT_MS) ?? 500) : 500` |
|
|
133
|
+
| revalidateTagQuerySize | Number of entries to query in one batch during full sync of shared tags hash map | `250` |
|
|
134
|
+
| avgResyncIntervalMs | Average interval in milliseconds between tag map full re-syncs | `3600000` (1 hour) |
|
|
135
|
+
| redisGetDeduplication | Enable deduplication of Redis get requests via internal in-memory cache. | `true` |
|
|
136
|
+
| inMemoryCachingTime | Time in milliseconds to cache Redis get results in memory. Set this to 0 to disable in-memory caching completely. | `10000` |
|
|
137
|
+
| defaultStaleAge | Default stale age in seconds for cached items | `1209600` (14 days) |
|
|
138
|
+
| estimateExpireAge | Function to calculate expire age (redis TTL value) from stale age | Production: `staleAge * 2`<br> Other: `staleAge * 1.2` |
|
|
139
|
+
| socketOptions | Redis client socket options for TLS/SSL configuration (e.g., `{ tls: true, rejectUnauthorized: false }`) | `{ connectTimeout: timeoutMs }` |
|
|
140
|
+
| clientOptions | Additional Redis client options (e.g., username, password) | `undefined` |
|
|
141
|
+
| killContainerOnErrorThreshold | Number of consecutive errors before the container is killed. Set to 0 to disable. | `Number.parseInt(process.env.KILL_CONTAINER_ON_ERROR_THRESHOLD) ?? 0 : 0` |
|
|
142
142
|
|
|
143
143
|
## TLS Configuration
|
|
144
144
|
|
package/dist/index.d.mts
CHANGED
|
@@ -20,10 +20,12 @@ type CreateRedisStringsHandlerOptions = {
|
|
|
20
20
|
* @default process.env.VERCEL_URL || 'UNDEFINED_URL_'
|
|
21
21
|
*/
|
|
22
22
|
keyPrefix?: string;
|
|
23
|
-
/** Timeout in milliseconds for Redis operations
|
|
24
|
-
*
|
|
23
|
+
/** Timeout in milliseconds for time critical Redis operations (during cache get, which blocks site rendering).
|
|
24
|
+
* If redis get is not fulfilled within this time, the cache handler will return null so site rendering will
|
|
25
|
+
* not be blocked further and site can fallback to re-render/re-fetch the content.
|
|
26
|
+
* @default 500
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
getTimeoutMs?: number;
|
|
27
29
|
/** Number of entries to query in one batch during full sync of shared tags hash map
|
|
28
30
|
* @default 250
|
|
29
31
|
*/
|
|
@@ -70,17 +72,17 @@ declare class RedisStringsHandler {
|
|
|
70
72
|
private sharedTagsMap;
|
|
71
73
|
private revalidatedTagsMap;
|
|
72
74
|
private inMemoryDeduplicationCache;
|
|
75
|
+
private getTimeoutMs;
|
|
73
76
|
private redisGet;
|
|
74
77
|
private redisDeduplicationHandler;
|
|
75
78
|
private deduplicatedRedisGet;
|
|
76
|
-
private timeoutMs;
|
|
77
79
|
private keyPrefix;
|
|
78
80
|
private redisGetDeduplication;
|
|
79
81
|
private inMemoryCachingTime;
|
|
80
82
|
private defaultStaleAge;
|
|
81
83
|
private estimateExpireAge;
|
|
82
84
|
private killContainerOnErrorThreshold;
|
|
83
|
-
constructor({ redisUrl, database, keyPrefix, sharedTagsKey,
|
|
85
|
+
constructor({ redisUrl, database, keyPrefix, sharedTagsKey, getTimeoutMs, revalidateTagQuerySize, avgResyncIntervalMs, redisGetDeduplication, inMemoryCachingTime, defaultStaleAge, estimateExpireAge, killContainerOnErrorThreshold, socketOptions, clientOptions, }: CreateRedisStringsHandlerOptions);
|
|
84
86
|
resetRequestCache(): void;
|
|
85
87
|
private clientReadyCalls;
|
|
86
88
|
private assertClientIsReady;
|
package/dist/index.d.ts
CHANGED
|
@@ -20,10 +20,12 @@ type CreateRedisStringsHandlerOptions = {
|
|
|
20
20
|
* @default process.env.VERCEL_URL || 'UNDEFINED_URL_'
|
|
21
21
|
*/
|
|
22
22
|
keyPrefix?: string;
|
|
23
|
-
/** Timeout in milliseconds for Redis operations
|
|
24
|
-
*
|
|
23
|
+
/** Timeout in milliseconds for time critical Redis operations (during cache get, which blocks site rendering).
|
|
24
|
+
* If redis get is not fulfilled within this time, the cache handler will return null so site rendering will
|
|
25
|
+
* not be blocked further and site can fallback to re-render/re-fetch the content.
|
|
26
|
+
* @default 500
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
getTimeoutMs?: number;
|
|
27
29
|
/** Number of entries to query in one batch during full sync of shared tags hash map
|
|
28
30
|
* @default 250
|
|
29
31
|
*/
|
|
@@ -70,17 +72,17 @@ declare class RedisStringsHandler {
|
|
|
70
72
|
private sharedTagsMap;
|
|
71
73
|
private revalidatedTagsMap;
|
|
72
74
|
private inMemoryDeduplicationCache;
|
|
75
|
+
private getTimeoutMs;
|
|
73
76
|
private redisGet;
|
|
74
77
|
private redisDeduplicationHandler;
|
|
75
78
|
private deduplicatedRedisGet;
|
|
76
|
-
private timeoutMs;
|
|
77
79
|
private keyPrefix;
|
|
78
80
|
private redisGetDeduplication;
|
|
79
81
|
private inMemoryCachingTime;
|
|
80
82
|
private defaultStaleAge;
|
|
81
83
|
private estimateExpireAge;
|
|
82
84
|
private killContainerOnErrorThreshold;
|
|
83
|
-
constructor({ redisUrl, database, keyPrefix, sharedTagsKey,
|
|
85
|
+
constructor({ redisUrl, database, keyPrefix, sharedTagsKey, getTimeoutMs, revalidateTagQuerySize, avgResyncIntervalMs, redisGetDeduplication, inMemoryCachingTime, defaultStaleAge, estimateExpireAge, killContainerOnErrorThreshold, socketOptions, clientOptions, }: CreateRedisStringsHandlerOptions);
|
|
84
86
|
resetRequestCache(): void;
|
|
85
87
|
private clientReadyCalls;
|
|
86
88
|
private assertClientIsReady;
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,6 @@ var SyncedMap = class {
|
|
|
58
58
|
this.redisKey = options.redisKey;
|
|
59
59
|
this.syncChannel = `${options.keyPrefix}${SYNC_CHANNEL_SUFFIX}${options.redisKey}`;
|
|
60
60
|
this.database = options.database;
|
|
61
|
-
this.timeoutMs = options.timeoutMs;
|
|
62
61
|
this.querySize = options.querySize;
|
|
63
62
|
this.filterKeys = options.filterKeys;
|
|
64
63
|
this.resyncIntervalMs = options.resyncIntervalMs;
|
|
@@ -89,9 +88,8 @@ var SyncedMap = class {
|
|
|
89
88
|
try {
|
|
90
89
|
do {
|
|
91
90
|
const remoteItems = await redisErrorHandler(
|
|
92
|
-
"SyncedMap.initialSync(), operation: hScan " + this.syncChannel + " " + this.
|
|
91
|
+
"SyncedMap.initialSync(), operation: hScan " + this.syncChannel + " " + this.keyPrefix + " " + this.redisKey + " " + cursor + " " + this.querySize,
|
|
93
92
|
this.client.hScan(
|
|
94
|
-
getTimeoutRedisCommandOptions(this.timeoutMs),
|
|
95
93
|
this.keyPrefix + this.redisKey,
|
|
96
94
|
cursor,
|
|
97
95
|
hScanOptions
|
|
@@ -118,12 +116,8 @@ var SyncedMap = class {
|
|
|
118
116
|
try {
|
|
119
117
|
do {
|
|
120
118
|
const remoteKeysPortion = await redisErrorHandler(
|
|
121
|
-
"SyncedMap.cleanupKeysNotInRedis(), operation: scan " + this.
|
|
122
|
-
this.client.scan(
|
|
123
|
-
getTimeoutRedisCommandOptions(this.timeoutMs),
|
|
124
|
-
cursor,
|
|
125
|
-
scanOptions
|
|
126
|
-
)
|
|
119
|
+
"SyncedMap.cleanupKeysNotInRedis(), operation: scan " + this.keyPrefix,
|
|
120
|
+
this.client.scan(cursor, scanOptions)
|
|
127
121
|
);
|
|
128
122
|
remoteKeys = remoteKeys.concat(remoteKeysPortion.keys);
|
|
129
123
|
cursor = remoteKeysPortion.cursor;
|
|
@@ -276,12 +270,10 @@ var SyncedMap = class {
|
|
|
276
270
|
return;
|
|
277
271
|
}
|
|
278
272
|
if (!this.customizedSync?.withoutRedisHashmap) {
|
|
279
|
-
const options = getTimeoutRedisCommandOptions(this.timeoutMs);
|
|
280
273
|
operations.push(
|
|
281
274
|
redisErrorHandler(
|
|
282
|
-
"SyncedMap.set(), operation: hSet " + this.syncChannel + " " + this.
|
|
275
|
+
"SyncedMap.set(), operation: hSet " + this.syncChannel + " " + this.keyPrefix + " " + key,
|
|
283
276
|
this.client.hSet(
|
|
284
|
-
options,
|
|
285
277
|
this.keyPrefix + this.redisKey,
|
|
286
278
|
key,
|
|
287
279
|
JSON.stringify(value)
|
|
@@ -296,7 +288,7 @@ var SyncedMap = class {
|
|
|
296
288
|
};
|
|
297
289
|
operations.push(
|
|
298
290
|
redisErrorHandler(
|
|
299
|
-
"SyncedMap.set(), operation: publish " + this.syncChannel + " " + this.
|
|
291
|
+
"SyncedMap.set(), operation: publish " + this.syncChannel + " " + this.keyPrefix + " " + key,
|
|
300
292
|
this.client.publish(this.syncChannel, JSON.stringify(insertMessage))
|
|
301
293
|
)
|
|
302
294
|
);
|
|
@@ -315,11 +307,10 @@ var SyncedMap = class {
|
|
|
315
307
|
this.map.delete(key);
|
|
316
308
|
}
|
|
317
309
|
if (!this.customizedSync?.withoutRedisHashmap) {
|
|
318
|
-
const options = getTimeoutRedisCommandOptions(this.timeoutMs * 10);
|
|
319
310
|
operations.push(
|
|
320
311
|
redisErrorHandler(
|
|
321
|
-
"SyncedMap.delete(), operation: hDel " + this.syncChannel + " " + this.
|
|
322
|
-
this.client.hDel(
|
|
312
|
+
"SyncedMap.delete(), operation: hDel " + this.syncChannel + " " + this.keyPrefix + " " + this.redisKey + " " + keysArray,
|
|
313
|
+
this.client.hDel(this.keyPrefix + this.redisKey, keysArray)
|
|
323
314
|
)
|
|
324
315
|
);
|
|
325
316
|
}
|
|
@@ -330,7 +321,7 @@ var SyncedMap = class {
|
|
|
330
321
|
};
|
|
331
322
|
operations.push(
|
|
332
323
|
redisErrorHandler(
|
|
333
|
-
"SyncedMap.delete(), operation: publish " + this.syncChannel + " " + this.
|
|
324
|
+
"SyncedMap.delete(), operation: publish " + this.syncChannel + " " + this.keyPrefix + " " + keysArray,
|
|
334
325
|
this.client.publish(
|
|
335
326
|
this.syncChannel,
|
|
336
327
|
JSON.stringify(deletionMessage)
|
|
@@ -482,12 +473,9 @@ setInterval(() => {
|
|
|
482
473
|
);
|
|
483
474
|
}
|
|
484
475
|
});
|
|
485
|
-
},
|
|
476
|
+
}, 10);
|
|
486
477
|
var NEXT_CACHE_IMPLICIT_TAG_ID = "_N_T_";
|
|
487
478
|
var REVALIDATED_TAGS_KEY = "__revalidated_tags__";
|
|
488
|
-
function getTimeoutRedisCommandOptions(timeoutMs) {
|
|
489
|
-
return (0, import_redis.commandOptions)({ signal: AbortSignal.timeout(timeoutMs) });
|
|
490
|
-
}
|
|
491
479
|
var killContainerOnErrorCount = 0;
|
|
492
480
|
var RedisStringsHandler = class {
|
|
493
481
|
constructor({
|
|
@@ -495,7 +483,7 @@ var RedisStringsHandler = class {
|
|
|
495
483
|
database = process.env.VERCEL_ENV === "production" ? 0 : 1,
|
|
496
484
|
keyPrefix = process.env.VERCEL_URL || "UNDEFINED_URL_",
|
|
497
485
|
sharedTagsKey = "__sharedTags__",
|
|
498
|
-
|
|
486
|
+
getTimeoutMs = process.env.REDIS_COMMAND_TIMEOUT_MS ? Number.parseInt(process.env.REDIS_COMMAND_TIMEOUT_MS) ?? 500 : 500,
|
|
499
487
|
revalidateTagQuerySize = 250,
|
|
500
488
|
avgResyncIntervalMs = 60 * 60 * 1e3,
|
|
501
489
|
redisGetDeduplication = true,
|
|
@@ -509,12 +497,12 @@ var RedisStringsHandler = class {
|
|
|
509
497
|
this.clientReadyCalls = 0;
|
|
510
498
|
try {
|
|
511
499
|
this.keyPrefix = keyPrefix;
|
|
512
|
-
this.timeoutMs = timeoutMs;
|
|
513
500
|
this.redisGetDeduplication = redisGetDeduplication;
|
|
514
501
|
this.inMemoryCachingTime = inMemoryCachingTime;
|
|
515
502
|
this.defaultStaleAge = defaultStaleAge;
|
|
516
503
|
this.estimateExpireAge = estimateExpireAge;
|
|
517
504
|
this.killContainerOnErrorThreshold = killContainerOnErrorThreshold;
|
|
505
|
+
this.getTimeoutMs = getTimeoutMs;
|
|
518
506
|
try {
|
|
519
507
|
this.client = (0, import_redis.createClient)({
|
|
520
508
|
url: redisUrl,
|
|
@@ -571,7 +559,6 @@ var RedisStringsHandler = class {
|
|
|
571
559
|
keyPrefix,
|
|
572
560
|
redisKey: sharedTagsKey,
|
|
573
561
|
database,
|
|
574
|
-
timeoutMs,
|
|
575
562
|
querySize: revalidateTagQuerySize,
|
|
576
563
|
filterKeys,
|
|
577
564
|
resyncIntervalMs: avgResyncIntervalMs - avgResyncIntervalMs / 10 + Math.random() * (avgResyncIntervalMs / 10)
|
|
@@ -581,7 +568,6 @@ var RedisStringsHandler = class {
|
|
|
581
568
|
keyPrefix,
|
|
582
569
|
redisKey: REVALIDATED_TAGS_KEY,
|
|
583
570
|
database,
|
|
584
|
-
timeoutMs,
|
|
585
571
|
querySize: revalidateTagQuerySize,
|
|
586
572
|
filterKeys,
|
|
587
573
|
resyncIntervalMs: avgResyncIntervalMs + avgResyncIntervalMs / 10 + Math.random() * (avgResyncIntervalMs / 10)
|
|
@@ -591,7 +577,6 @@ var RedisStringsHandler = class {
|
|
|
591
577
|
keyPrefix,
|
|
592
578
|
redisKey: "inMemoryDeduplicationCache",
|
|
593
579
|
database,
|
|
594
|
-
timeoutMs,
|
|
595
580
|
querySize: revalidateTagQuerySize,
|
|
596
581
|
filterKeys,
|
|
597
582
|
customizedSync: {
|
|
@@ -644,7 +629,7 @@ var RedisStringsHandler = class {
|
|
|
644
629
|
"assertClientIsReady: Timeout waiting for Redis maps to be ready"
|
|
645
630
|
)
|
|
646
631
|
);
|
|
647
|
-
},
|
|
632
|
+
}, 3e4)
|
|
648
633
|
)
|
|
649
634
|
]);
|
|
650
635
|
this.clientReadyCalls = 0;
|
|
@@ -669,9 +654,9 @@ var RedisStringsHandler = class {
|
|
|
669
654
|
await this.assertClientIsReady();
|
|
670
655
|
const clientGet = this.redisGetDeduplication ? this.deduplicatedRedisGet(key) : this.redisGet;
|
|
671
656
|
const serializedCacheEntry = await redisErrorHandler(
|
|
672
|
-
"RedisStringsHandler.get(), operation: get" + (this.redisGetDeduplication ? "deduplicated" : "") + this.
|
|
657
|
+
"RedisStringsHandler.get(), operation: get" + (this.redisGetDeduplication ? "deduplicated" : "") + " " + this.getTimeoutMs + "ms " + this.keyPrefix + " " + key,
|
|
673
658
|
clientGet(
|
|
674
|
-
|
|
659
|
+
(0, import_redis.commandOptions)({ signal: AbortSignal.timeout(this.getTimeoutMs) }),
|
|
675
660
|
this.keyPrefix + key
|
|
676
661
|
)
|
|
677
662
|
);
|
|
@@ -731,7 +716,7 @@ var RedisStringsHandler = class {
|
|
|
731
716
|
const revalidationTime = this.revalidatedTagsMap.get(tag);
|
|
732
717
|
if (revalidationTime && revalidationTime > cacheEntry.lastModified) {
|
|
733
718
|
const redisKey = this.keyPrefix + key;
|
|
734
|
-
this.client.unlink(
|
|
719
|
+
this.client.unlink(redisKey).catch((err) => {
|
|
735
720
|
console.error(
|
|
736
721
|
"Error occurred while unlinking stale data. Error was:",
|
|
737
722
|
err
|
|
@@ -808,10 +793,9 @@ var RedisStringsHandler = class {
|
|
|
808
793
|
data.kind === "FETCH" && data.revalidate || ctx.revalidate || ctx.cacheControl?.revalidate || data?.revalidate
|
|
809
794
|
);
|
|
810
795
|
const expireAt = revalidate && Number.isSafeInteger(revalidate) && revalidate > 0 ? this.estimateExpireAge(revalidate) : this.estimateExpireAge(this.defaultStaleAge);
|
|
811
|
-
const options = getTimeoutRedisCommandOptions(this.timeoutMs);
|
|
812
796
|
const setOperation = redisErrorHandler(
|
|
813
|
-
"RedisStringsHandler.set(), operation: set
|
|
814
|
-
this.client.set(
|
|
797
|
+
"RedisStringsHandler.set(), operation: set " + this.keyPrefix + " " + key,
|
|
798
|
+
this.client.set(this.keyPrefix + key, serializedCacheEntry, {
|
|
815
799
|
EX: expireAt
|
|
816
800
|
})
|
|
817
801
|
);
|
|
@@ -905,10 +889,9 @@ var RedisStringsHandler = class {
|
|
|
905
889
|
}
|
|
906
890
|
const redisKeys = Array.from(keysToDelete);
|
|
907
891
|
const fullRedisKeys = redisKeys.map((key) => this.keyPrefix + key);
|
|
908
|
-
const options = getTimeoutRedisCommandOptions(this.timeoutMs);
|
|
909
892
|
const deleteKeysOperation = redisErrorHandler(
|
|
910
|
-
"RedisStringsHandler.revalidateTag(), operation: unlink
|
|
911
|
-
this.client.unlink(
|
|
893
|
+
"RedisStringsHandler.revalidateTag(), operation: unlink " + this.keyPrefix + " " + fullRedisKeys,
|
|
894
|
+
this.client.unlink(fullRedisKeys)
|
|
912
895
|
);
|
|
913
896
|
if (this.redisGetDeduplication && this.inMemoryCachingTime > 0) {
|
|
914
897
|
for (const key of keysToDelete) {
|