mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-17 09:43:43 +08:00
20 lines
417 B
TypeScript
20 lines
417 B
TypeScript
import 'server-only';
|
|
|
|
import { Redis } from '@upstash/redis';
|
|
|
|
let cachedRedis: Redis | null | undefined;
|
|
|
|
export function getRedisClient(): Redis | null {
|
|
if (cachedRedis !== undefined) {
|
|
return cachedRedis;
|
|
}
|
|
|
|
if (!process.env.UPSTASH_REDIS_REST_URL || !process.env.UPSTASH_REDIS_REST_TOKEN) {
|
|
cachedRedis = null;
|
|
return cachedRedis;
|
|
}
|
|
|
|
cachedRedis = Redis.fromEnv();
|
|
return cachedRedis;
|
|
}
|