UNPKG

@fortedigital/nextjs-cache-handler

Version:
24 lines (21 loc) 1.29 kB
import { Handler } from './cache-handler.types.cjs'; import { CreateCompositeHandlerOptions } from './composite.types.cjs'; import 'next/dist/server/lib/incremental-cache'; import 'next/dist/server/lib/incremental-cache/file-system-cache'; /** * Creates a composite Handler for managing cache operations using multiple handlers. * * This function initializes a composite Handler that coordinates cache operations * across multiple handlers, providing methods for getting, setting, and revalidating cache values. * * @param options - The configuration options for the composite handler. See {@link CreateCompositeHandlerOptions}. * * @returns An object representing the composite cache handler, with methods for cache operations. * * @remarks * - The `get` method retrieves a value from the first handler that returns a non-null result, in the order defined by the handlers array. * - The `set` method uses the `setStrategy` to determine which handler should store the data. If no strategy is provided, the first handler is used. * - The `revalidateTag` and `delete` methods apply the operation across all handlers in parallel. */ declare function createHandler({ handlers, setStrategy: strategy, }: CreateCompositeHandlerOptions): Handler; export { createHandler as default };