diff --git a/README.md b/README.md index e0de775..ac76529 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,24 @@ const redisCacheHandler = createRedisHandler({ **Note:** Redis Cluster support is currently experimental and may have limitations or unexpected bugs. Use it with caution. +#### Redis Sentinel + +```js +import { createSentinel } from "@redis/"; +import createRedisHandler from "@fortedigital/nextjs-cache-handler/redis-strings"; + +const redisHandler = await createRedisHandler({ + client: createSentinel({ + url: process.env.REDIS_URL, + }), + keyPrefix: "myApp:", + sharedTagsKey: "myTags", + sharedTagsTtlKey: "myTagTtls", +}); +``` + +**Note:** Redis Sentinel support is currently experimental and may have limitations or unexpected bugs. Use it with caution. + --- ### `local-lru` diff --git a/packages/nextjs-cache-handler/src/handlers/redis-strings.ts b/packages/nextjs-cache-handler/src/handlers/redis-strings.ts index 2355d6f..a4f88ee 100644 --- a/packages/nextjs-cache-handler/src/handlers/redis-strings.ts +++ b/packages/nextjs-cache-handler/src/handlers/redis-strings.ts @@ -6,7 +6,7 @@ import { convertStringsToBuffers, parseBuffersToStrings, } from "../helpers/buffer"; -import type { RedisClientType } from "@redis/client"; +import type { RedisClientType, RedisSentinelType } from "@redis/client"; import { RedisClusterCacheAdapter } from "../helpers/redisClusterAdapter"; import { withAbortSignalProxy } from "../helpers/withAbortSignalProxy"; @@ -34,7 +34,7 @@ export default function createHandler({ keyExpirationStrategy = "EXPIREAT", revalidateTagQuerySize = 10_000, }: CreateRedisStringsHandlerOptions< - RedisClientType | RedisClusterCacheAdapter + RedisClientType | RedisClusterCacheAdapter | RedisSentinelType >): Handler { const client = withAbortSignalProxy(innerClient); const revalidatedTagsKey = keyPrefix + REVALIDATED_TAGS_KEY; diff --git a/packages/nextjs-cache-handler/src/handlers/redis-strings.types.ts b/packages/nextjs-cache-handler/src/handlers/redis-strings.types.ts index 3ba219a..7705df6 100644 --- a/packages/nextjs-cache-handler/src/handlers/redis-strings.types.ts +++ b/packages/nextjs-cache-handler/src/handlers/redis-strings.types.ts @@ -1,4 +1,4 @@ -import type { RedisClientType } from "@redis/client"; +import type { RedisClientType, RedisSentinelType } from "@redis/client"; import { RedisClusterCacheAdapter } from "../helpers/redisClusterAdapter"; export type RedisCompliantCachedRouteValue = { @@ -15,7 +15,7 @@ export type RedisCompliantCachedAppPageValue = { }; export type CreateRedisStringsHandlerOptions< - T = RedisClientType | RedisClusterCacheAdapter, + T = RedisClientType | RedisClusterCacheAdapter | RedisSentinelType, > = { /** * The Redis client instance.