import { redis } from './redis'; export function cacheable any>( fn: T, expire: number ) { return async function (...args: Parameters): Promise> { const key = `cachable:${fn.name}:${JSON.stringify(args)}`; const cached = await redis.get(key); if (cached) { return JSON.parse(cached); } const result = await fn(...(args as any)); redis.setex(key, expire, JSON.stringify(result)); return result; }; }