import { Redis } from '@upstash/redis'; // Upstash Redis client for serverless/Vercel compatibility. // For self-hosted Docker, run redis-rest-proxy or use Upstash Cloud free tier. // Env vars: UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN const url = process.env.UPSTASH_REDIS_REST_URL; const token = process.env.UPSTASH_REDIS_REST_TOKEN; export const redis = url && token ? new Redis({ url, token }) : null; export function ensureRedis() { if (!redis) { throw new Error('Redis is not configured. Set UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.'); } return redis; }