import RedisStringsHandler, { type CreateRedisStringsHandlerOptions, } from "./RedisStringsHandler"; import { debugVerbose } from "./utils/debug"; let cachedHandler: RedisStringsHandler; // Function to reset the cached handler (for testing) export function resetCachedHandler() { cachedHandler = undefined as any; } export default class CachedHandler { constructor(options: CreateRedisStringsHandlerOptions) { if (!cachedHandler) { cachedHandler = new RedisStringsHandler(options); } } get( ...args: Parameters ): ReturnType { debugVerbose("CachedHandler.get called with", args); return cachedHandler.get(...args); } set( ...args: Parameters ): ReturnType { debugVerbose("CachedHandler.set called with", args); return cachedHandler.set(...args); } revalidateTag( ...args: Parameters ): ReturnType { debugVerbose("CachedHandler.revalidateTag called with", args); return cachedHandler.revalidateTag(...args); } resetRequestCache( ...args: Parameters ): ReturnType { // debug("CachedHandler.resetRequestCache called with", args); return cachedHandler.resetRequestCache(...args); } }