Spaces:
Running
Running
File size: 629 Bytes
c01955c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import { Redis } from "ioredis";
import dotenv from "dotenv";
import logger from "../logger/create.logger.js";
dotenv.config();
const client = new Redis(process.env.REDIS_URL || "redis://localhost:6379", {
maxRetriesPerRequest: 1,
retryStrategy(times) {
// Retry less frequently to avoid spamming connection attempts
return Math.min(times * 500, 10000);
},
});
// Silent error listener to prevent "Unhandled error event" crashes
// while keeping the console clean as requested by the user.
client.on("error", (err) => {
logger.error("Redis connection error:", err);
});
export default client; |