@trieb.work/nextjs-turbo-redis-cache 1.16.0 → 1.16.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/CHANGELOG.md +14 -0
- package/README.md +8 -0
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/CacheComponentsHandler.ts +35 -2
- package/src/RedisStringsHandler.ts +26 -15
- package/test/vitest/integration/cache-components/redis-kill-reconnect.test.ts +6 -0
- package/test/vitest/integration/cache-components/scripts/redis-kill-reconnect.ts +3 -5
- package/test/vitest/unit/index.test.ts +77 -2
- package/test/vitest/unit/reconnect-socket-already-opened.test.ts +56 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.16.2](https://github.com/trieb-work/nextjs-turbo-redis-cache/compare/v1.16.1...v1.16.2) (2026-08-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* clear the readiness-timeout timer leaked on every cache operation ([#90](https://github.com/trieb-work/nextjs-turbo-redis-cache/issues/90)) ([ab542e3](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/ab542e3e83bef53c863d7affa916adb9de8ad935))
|
|
7
|
+
|
|
8
|
+
## [1.16.1](https://github.com/trieb-work/nextjs-turbo-redis-cache/compare/v1.16.0...v1.16.1) (2026-08-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* make redisCacheHandler lazy to avoid import-time Redis connection (supersedes [#85](https://github.com/trieb-work/nextjs-turbo-redis-cache/issues/85)) ([#92](https://github.com/trieb-work/nextjs-turbo-redis-cache/issues/92)) ([2d0b063](https://github.com/trieb-work/nextjs-turbo-redis-cache/commit/2d0b063176596ecd0fed385ba66bbc50e0c64fcc))
|
|
14
|
+
|
|
1
15
|
# [1.16.0](https://github.com/trieb-work/nextjs-turbo-redis-cache/compare/v1.15.0...v1.16.0) (2026-08-13)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -505,6 +505,14 @@ Optional:
|
|
|
505
505
|
- `VERCEL_URL`: used as a key prefix for multi-tenant isolation (also useful in tests). If unset, a default prefix is used.
|
|
506
506
|
- `REDIS_COMMAND_TIMEOUT_MS`: timeout (ms) for Redis commands used by the handler.
|
|
507
507
|
|
|
508
|
+
### Lazy initialization
|
|
509
|
+
|
|
510
|
+
The `redisCacheHandler` export is **lazily initialized** — importing the package does **not** open a Redis connection. The connection is deferred until the first method call on the handler (when Next.js invokes it). This means:
|
|
511
|
+
|
|
512
|
+
- Importing the package (e.g. for `RedisStringsHandler` only) never opens a Redis connection, even if Cache Components is not used.
|
|
513
|
+
- `getRedisCacheComponentsHandler(options)` can be called with custom options **before** first use to configure the singleton.
|
|
514
|
+
- If `getRedisCacheComponentsHandler(options)` is called **after** the handler has already been used, the options are ignored (the singleton is already constructed).
|
|
515
|
+
|
|
508
516
|
### Local manual testing (Cache Lab)
|
|
509
517
|
|
|
510
518
|
This repo includes a dedicated Next.js Cache Components integration app with real pages for manual testing.
|
package/dist/index.js
CHANGED
|
@@ -720,21 +720,26 @@ var RedisStringsHandler = class {
|
|
|
720
720
|
"assertClientIsReady called more than 10 times without being ready."
|
|
721
721
|
);
|
|
722
722
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
723
|
+
let readyTimeout;
|
|
724
|
+
try {
|
|
725
|
+
await Promise.race([
|
|
726
|
+
Promise.all([
|
|
727
|
+
this.sharedTagsMap.waitUntilReady(),
|
|
728
|
+
this.revalidatedTagsMap.waitUntilReady()
|
|
729
|
+
]),
|
|
730
|
+
new Promise((_, reject) => {
|
|
731
|
+
readyTimeout = setTimeout(() => {
|
|
732
|
+
reject(
|
|
733
|
+
new Error(
|
|
734
|
+
"assertClientIsReady: Timeout waiting for Redis maps to be ready"
|
|
735
|
+
)
|
|
736
|
+
);
|
|
737
|
+
}, 3e4);
|
|
738
|
+
})
|
|
739
|
+
]);
|
|
740
|
+
} finally {
|
|
741
|
+
clearTimeout(readyTimeout);
|
|
742
|
+
}
|
|
738
743
|
this.clientReadyCalls = 0;
|
|
739
744
|
if (!this.client.isReady) {
|
|
740
745
|
throw new Error(
|
|
@@ -1468,7 +1473,22 @@ function getRedisCacheComponentsHandler(options = {}) {
|
|
|
1468
1473
|
}
|
|
1469
1474
|
return singletonHandler;
|
|
1470
1475
|
}
|
|
1471
|
-
var
|
|
1476
|
+
var resolvedHandler;
|
|
1477
|
+
var redisCacheHandler = new Proxy(
|
|
1478
|
+
{},
|
|
1479
|
+
{
|
|
1480
|
+
get(_target, prop) {
|
|
1481
|
+
if (!resolvedHandler) {
|
|
1482
|
+
resolvedHandler = getRedisCacheComponentsHandler();
|
|
1483
|
+
}
|
|
1484
|
+
const value = resolvedHandler[prop];
|
|
1485
|
+
return typeof value === "function" ? value.bind(resolvedHandler) : value;
|
|
1486
|
+
},
|
|
1487
|
+
has(_target, prop) {
|
|
1488
|
+
return prop in RedisCacheComponentsHandler.prototype;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
);
|
|
1472
1492
|
|
|
1473
1493
|
// src/index.ts
|
|
1474
1494
|
var index_default = CachedHandler;
|