48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
/**
|
|
* Copyright (c) 2026 Niolla
|
|
* All rights reserved.
|
|
*
|
|
* This source code is proprietary and confidential.
|
|
* Unauthorized copying, modification, distribution, or use
|
|
* of this file, via any medium, is strictly prohibited.
|
|
*/
|
|
|
|
// app/config/redis.config.js
|
|
|
|
const { Redis } = require("ioredis");
|
|
|
|
const createRedisConnection = () => {
|
|
const redis = new Redis({
|
|
host: process.env.REDIS_HOST || "redis",
|
|
port: process.env.REDIS_PORT || 6379,
|
|
password: process.env.REDIS_PASSWORD,
|
|
maxRetriesPerRequest: null,
|
|
enableReadyCheck: false,
|
|
});
|
|
|
|
// Connection events
|
|
redis.on("connect", () => {
|
|
console.log("Redis connecting...");
|
|
});
|
|
|
|
redis.on("ready", () => {
|
|
console.log("Redis connected and ready!");
|
|
});
|
|
|
|
redis.on("error", (err) => {
|
|
console.error("Redis error:", err.message);
|
|
});
|
|
|
|
redis.on("close", () => {
|
|
console.warn("Redis connection closed");
|
|
});
|
|
|
|
redis.on("reconnecting", () => {
|
|
console.log("Redis reconnecting...");
|
|
});
|
|
|
|
return redis;
|
|
};
|
|
|
|
module.exports = createRedisConnection;
|