UNPKG

@fortedigital/nextjs-cache-handler

Version:
27 lines (24 loc) 1.59 kB
import { Handler } from './cache-handler.types.js'; import { CreateRedisStringsHandlerOptions, CacheValueSerializer } from './redis-strings.types.js'; import { RedisClientType } from '@redis/client'; import { RedisClusterCacheAdapter } from '../helpers/redisClusterAdapter.js'; import 'next/dist/server/lib/incremental-cache'; import 'next/dist/server/lib/incremental-cache/file-system-cache'; declare const jsonCacheValueSerializer: CacheValueSerializer; /** * Creates a Handler for handling cache operations using Redis strings. * * This function initializes a Handler for managing cache operations using Redis. * It supports Redis Client and includes methods for on-demand revalidation of cache values. * * @param options - The configuration options for the Redis Handler. See {@link CreateRedisStringsHandlerOptions}. * * @returns An object representing the Redis-based cache handler, with methods for cache operations. * * @remarks * - The `get` method retrieves a value from the cache, automatically converting `Buffer` types when necessary. * - The `set` method stores a value in the cache, using the configured expiration strategy. * - The `revalidateTag` and `delete` methods handle cache revalidation and deletion. */ declare function createHandler({ client: innerClient, keyPrefix, sharedTagsKey, sharedTagsTtlKey, timeoutMs, keyExpirationStrategy, revalidateTagQuerySize, valueSerializer, }: CreateRedisStringsHandlerOptions<RedisClientType | RedisClusterCacheAdapter>): Handler; export { CacheValueSerializer, createHandler as default, jsonCacheValueSerializer };