Refactored permissions check. Updated redis lib.
This commit is contained in:
10
lib/redis.js
10
lib/redis.js
@@ -3,16 +3,18 @@ import debug from 'debug';
|
||||
|
||||
const log = debug('umami:redis');
|
||||
const REDIS = Symbol();
|
||||
const DELETED = 'DELETED';
|
||||
|
||||
let redis;
|
||||
const enabled = Boolean(process.env.REDIS_URL);
|
||||
const url = process.env.REDIS_URL;
|
||||
const enabled = Boolean(url);
|
||||
|
||||
async function getClient() {
|
||||
if (!process.env.REDIS_URL) {
|
||||
if (!enabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const client = createClient({ url: process.env.REDIS_URL });
|
||||
const client = createClient({ url });
|
||||
client.on('error', err => log(err));
|
||||
await client.connect();
|
||||
|
||||
@@ -59,4 +61,4 @@ async function connect() {
|
||||
return redis;
|
||||
}
|
||||
|
||||
export default { enabled, client: redis, log, connect, get, set, del };
|
||||
export default { enabled, client: redis, log, connect, get, set, del, DELETED };
|
||||
|
||||
Reference in New Issue
Block a user