Updated redis logic.

This commit is contained in:
Mike Cao committed 2025-02-10 21:07:18 -08:00
1 parent 39e7ceac06
commit 4d6ec631f7
9 files changed
+52 -46

No files matched your search

+17
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 };