feat: add Redis client singleton

This commit is contained in:
2001-01-01 00:00:00 +00:00
parent 10555d709e
commit 41ac84378c

12
apps/web/src/lib/redis.ts Normal file
View File

@@ -0,0 +1,12 @@
import IORedis from "ioredis";
let redis: IORedis | null = null;
export function getRedis(): IORedis {
if (!redis) {
redis = new IORedis(process.env.REDIS_URL ?? "redis://localhost:6379", {
maxRetriesPerRequest: null,
});
}
return redis;
}