Updated redis logic.

This commit is contained in:
Mike Cao 2025-02-10 21:07:18 -08:00
parent 39e7ceac06
commit 4d6ec631f7
9 changed files with 52 additions and 46 deletions

17
src/lib/redis.ts Normal file
View file

@ -0,0 +1,17 @@
import { REDIS, UmamiRedisClient } from '@umami/redis-client';
const enabled = !!process.env.REDIS_URL;
function getClient() {
const client = new UmamiRedisClient(process.env.REDIS_URL);
if (process.env.NODE_ENV !== 'production') {
global[REDIS] = client;
}
return client;
}
const client = global[REDIS] || getClient();
export default { client, enabled };