import { type RedisOptions } from "ioredis"; import type { CacheHandler, CacheHandlerContext, CacheHandlerGetMeta, CacheHandlerGetResult, CacheHandlerOptions, CacheValue } from "../types.js"; export interface RedisCacheHandlerOptions extends CacheHandlerOptions { /** * Redis connection options (ioredis) * Can be a URL string or RedisOptions object */ redis?: string | RedisOptions; /** * Key prefix for all cache entries * @default "nextjs:cache:" */ keyPrefix?: string; /** * Key prefix for tag tracking * @default "nextjs:tags:" */ tagPrefix?: string; /** * Default TTL in seconds for entries without explicit revalidate * @default undefined (no expiration) */ defaultTTL?: number; /** * Enable debug logging * @default false */ debug?: boolean; } /** * Redis cache handler for Next.js 16+ with Cache Components support * * Features: * - Persistent caching across server restarts * - Tag-based revalidation with Redis Sets * - TTL support with automatic expiration * - Compatible with Redis, ElastiCache, and Valkey * - Connection pooling via ioredis * * @example * ```typescript * // In cache-handler.mjs or data-cache-handler.mjs * import { RedisCacheHandler } from "@mrjasonroy/cache-components-cache-handler/handlers/redis"; * * export default class NextCacheHandler extends RedisCacheHandler { * constructor(options) { * super({ * ...options, * redis: process.env.REDIS_URL || "redis://localhost:6379", * keyPrefix: "nextjs:cache:", * defaultTTL: 3600 * }); * } * } * ``` */ export declare class RedisCacheHandler implements CacheHandler { readonly name = "redis"; private redis; private readonly keyPrefix; private readonly tagPrefix; private readonly defaultTTL?; private readonly debug; constructor(options?: RedisCacheHandlerOptions); private log; private getCacheKey; private getTagKey; get(key: string, meta?: CacheHandlerGetMeta): Promise; set(key: string, value: CacheValue, context?: CacheHandlerContext): Promise; revalidateTag(tag: string, _profile?: string | { expire?: number; }): Promise; delete(key: string): Promise; /** * Close the Redis connection * Call this when shutting down your application */ close(): Promise; } //# sourceMappingURL=redis.d.ts.map