Skip to content

Commit 37b45c4

Browse files
committed
Added redis sentinel support
1 parent 81a2565 commit 37b45c4

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,24 @@ const redisCacheHandler = createRedisHandler({
158158

159159
**Note:** Redis Cluster support is currently experimental and may have limitations or unexpected bugs. Use it with caution.
160160

161+
#### Redis Sentinel
162+
163+
```js
164+
import { createSentinel } from "@redis/";
165+
import createRedisHandler from "@fortedigital/nextjs-cache-handler/redis-strings";
166+
167+
const redisHandler = await createRedisHandler({
168+
client: createSentinel({
169+
url: process.env.REDIS_URL,
170+
}),
171+
keyPrefix: "myApp:",
172+
sharedTagsKey: "myTags",
173+
sharedTagsTtlKey: "myTagTtls",
174+
});
175+
```
176+
177+
**Note:** Redis Sentinel support is currently experimental and may have limitations or unexpected bugs. Use it with caution.
178+
161179
---
162180

163181
### `local-lru`

packages/nextjs-cache-handler/src/handlers/redis-strings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
convertStringsToBuffers,
77
parseBuffersToStrings,
88
} from "../helpers/buffer";
9-
import type { RedisClientType } from "@redis/client";
9+
import type { RedisClientType, RedisSentinelType } from "@redis/client";
1010
import { RedisClusterCacheAdapter } from "../helpers/redisClusterAdapter";
1111
import { withAbortSignalProxy } from "../helpers/withAbortSignalProxy";
1212

@@ -34,7 +34,7 @@ export default function createHandler({
3434
keyExpirationStrategy = "EXPIREAT",
3535
revalidateTagQuerySize = 10_000,
3636
}: CreateRedisStringsHandlerOptions<
37-
RedisClientType | RedisClusterCacheAdapter
37+
RedisClientType | RedisClusterCacheAdapter | RedisSentinelType
3838
>): Handler {
3939
const client = withAbortSignalProxy(innerClient);
4040
const revalidatedTagsKey = keyPrefix + REVALIDATED_TAGS_KEY;

packages/nextjs-cache-handler/src/handlers/redis-strings.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { RedisClientType } from "@redis/client";
1+
import type { RedisClientType, RedisSentinelType } from "@redis/client";
22
import { RedisClusterCacheAdapter } from "../helpers/redisClusterAdapter";
33

44
export type RedisCompliantCachedRouteValue = {
@@ -15,7 +15,7 @@ export type RedisCompliantCachedAppPageValue = {
1515
};
1616

1717
export type CreateRedisStringsHandlerOptions<
18-
T = RedisClientType | RedisClusterCacheAdapter,
18+
T = RedisClientType | RedisClusterCacheAdapter | RedisSentinelType,
1919
> = {
2020
/**
2121
* The Redis client instance.

0 commit comments

Comments
 (0)