@rb2bv/cache-handler
Version:
Next.js self-hosting simplified.
54 lines (51 loc) • 1.99 kB
TypeScript
import { createCluster } from 'redis';
import { Handler } from '../cache-handler.js';
import { C as CreateRedisStringsHandlerOptions } from '../common-types-D3MDcEyB.js';
import '../next-common-D8C6ukdH.js';
import 'next/dist/server/lib/incremental-cache';
import 'next/dist/server/lib/incremental-cache/file-system-cache';
import 'next/dist/server/response-cache/types';
type CreateRedisClusterHandlerOptions<T = ReturnType<typeof createCluster>> = CreateRedisStringsHandlerOptions & {
/**
* Use `cluster` instead of `client`.
*/
client: never;
/**
* The Redis cluster instance.
*
* @since 1.5.0
*/
cluster: T;
};
/**
* Creates a Handler for handling cache operations using Redis Cluster.
*
* ⚠️ This Handler is currently experimental and subject to change
* or removal in future updates without a major version increment.
* Use with caution.
*
* This function initializes a Handler for managing cache operations using Redis.
* It supports Redis Cluster. The resulting Handler includes
* methods to get, set, and manage cache values fot on-demand revalidation.
*
* @param options - The configuration options for the Redis Handler. See {@link CreateRedisClusterHandlerOptions}.
*
* @returns An object representing the cache, with methods for cache operations.
*
* @example
* ```js
* const cluster = createCluster(clusterOptions);
*
* const clusterHandler = await createHandler({
* cluster,
* keyPrefix: 'myApp:',
* });
* ```
*
* @remarks
* - the `get` method retrieves a value from the cache, automatically converting `Buffer` types when necessary.
* - the `set` method allows setting a value in the cache.
* - the `revalidateTag` methods are used for handling tag-based cache revalidation.
*/
declare function createHandler({ cluster, keyPrefix, sharedTagsKey, timeoutMs, keyExpirationStrategy, revalidateTagQuerySize, }: CreateRedisClusterHandlerOptions): Handler;
export { createHandler as default };