Updated redis logic.
This commit is contained in:
17
src/lib/redis.ts
Normal file
17
src/lib/redis.ts
Normal 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 };
|
||||
Reference in New Issue
Block a user