first commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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;
|
||||
Reference in New Issue
Block a user