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:
zyachel
2022-11-13 17:29:47 +05:30
parent 6f664d2164
commit 5fd0d92187
7 changed files with 148 additions and 73 deletions

View File

@ -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;