mirror of
https://github.com/AderKonstantin/aderktech-chronark.com-.git
synced 2025-06-08 13:48:42 +03:00
18 lines
410 B
TypeScript
18 lines
410 B
TypeScript
import Redis from "ioredis";
|
|
|
|
let redis: Redis | null = null;
|
|
|
|
export const getRedisClient = () => {
|
|
if (!redis) {
|
|
redis = new Redis({
|
|
host: process.env.REDIS_HOST || "localhost",
|
|
port: parseInt(process.env.REDIS_PORT || "6379"),
|
|
password: process.env.REDIS_PASSWORD,
|
|
});
|
|
|
|
redis.on("error", (err) => {
|
|
console.error("Redis error:", err);
|
|
});
|
|
}
|
|
return redis;
|
|
}; |