import { redisConfig, env } from "@/env";
import ioredis from "ioredis";

const redis = new ioredis({
    host: redisConfig.host,
    port: redisConfig.port,
    username: redisConfig.username,
    password: redisConfig.password,
    maxRetriesPerRequest: 1, // Avoid excessive retries,
    tls: !env.IS_DEV
        ? {
              rejectUnauthorized: true,
          }
        : undefined,
    lazyConnect: true,
    commandTimeout: 1_000,
    socketTimeout: 5_000,
});

export { redis };
