import { env } from "@/env";
import Redis, { type Redis as RedisType } from "ioredis";

const globalForRedis = globalThis as unknown as {
  redis: RedisType | undefined;
};

const redisInstance = globalForRedis.redis ?? new Redis();
if (env.NODE_ENV !== "production") globalForRedis.redis = redisInstance;

export const redis = redisInstance;
