fix(redis): fix logs being polluted when redis is disabled
also used streaming when redis is disabled for faster response.
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
import Redis from 'ioredis'
|
||||
import Redis from 'ioredis';
|
||||
|
||||
const redisUrl = process.env.REDIS_URL
|
||||
const redisUrl = process.env.REDIS_URL;
|
||||
const toUseRedis = process.env.USE_REDIS === 'true';
|
||||
|
||||
if (!redisUrl) {
|
||||
throw 'Please set the REDIS_URL environment variable.'
|
||||
}
|
||||
let redis: Redis | null;
|
||||
|
||||
const redis = new Redis(redisUrl)
|
||||
if (toUseRedis && redisUrl) redis = new Redis(redisUrl);
|
||||
else redis = null;
|
||||
|
||||
export default redis
|
||||
export default redis;
|
||||
|
Reference in New Issue
Block a user