Add createRedisClientForRepository method to deduplicate default Redis client in constructor

This commit is contained in:
2025-11-20 16:41:14 -08:00
parent b202189ad6
commit 645fe1055b
3 changed files with 20 additions and 20 deletions

View File

@@ -0,0 +1,14 @@
import { createClient, RedisClientType } from "redis";
import { REDIS_RECONNECT_INTERVAL } from "../environment";
export default function createRedisClientForRepository() {
const client = createClient({
url: process.env.REDIS_URL,
socket: {
tls: process.env.NODE_ENV === 'production',
rejectUnauthorized: false,
reconnectStrategy: REDIS_RECONNECT_INTERVAL,
},
});
return client as RedisClientType;
}