@@ -116,13 +116,48 @@ A Redis-based handler for key- and tag-based caching. Compared to the original i
116116import createRedisHandler from " @fortedigital/nextjs-cache-handler/redis-strings" ;
117117
118118const redisHandler = await createRedisHandler ({
119- client,
119+ client: createClient ({
120+ url: process .env .REDIS_URL ,
121+ }),
120122 keyPrefix: " myApp:" ,
121123 sharedTagsKey: " myTags" ,
122124 sharedTagsTtlKey: " myTagTtls" ,
123125});
124126```
125127
128+ #### Redis Cluster (Experimental)
129+
130+ ``` js
131+ import { createCluster } from " @redis/client" ;
132+ import createRedisHandler from " @fortedigital/nextjs-cache-handler/redis-strings" ;
133+ import { withAdapter } from " @fortedigital/nextjs-cache-handler/cluster/adapter" ;
134+
135+ const { hostname: redisHostName } = new URL (process .env .REDIS_URL );
136+ redis = withAdapter (
137+ createCluster ({
138+ rootNodes: [{ url: process .env .REDIS_URL }],
139+
140+ // optional if you use TLS and need to resolve shards' ip to proper hostname
141+ nodeAddressMap (address ) {
142+ const [_ , port ] = address .split (" :" );
143+
144+ return {
145+ host: redisHostName,
146+ port: Number (port),
147+ };
148+ },
149+ })
150+ );
151+
152+ // after using withAdapter you can use redis cluster instance as parameter for createRedisHandler
153+ const redisCacheHandler = createRedisHandler ({
154+ client: redis,
155+ keyPrefix: CACHE_PREFIX ,
156+ });
157+ ```
158+
159+ ** Note:** Redis Cluster support is currently experimental and may have limitations or unexpected bugs. Use it with caution.
160+
126161---
127162
128163### ` local-lru `
@@ -186,7 +221,8 @@ Next 15 decided to change types of some properties from String to Buffer which c
186221` ` ` js
187222import createBufferStringDecoratorHandler from " @fortedigital/nextjs-cache-handler/buffer-string-decorator" ;
188223
189- const bufferStringDecorator = createBufferStringDecoratorHandler (redisCacheHandler);
224+ const bufferStringDecorator =
225+ createBufferStringDecoratorHandler (redisCacheHandler);
190226` ` `
191227
192228## Examples
0 commit comments