From 5a0a297634afd46ba254d81b7eb6c98d2df27d04 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 9 Mar 2019 23:44:54 +0900 Subject: [PATCH] Improve redis config --- src/config/types.ts | 2 ++ src/db/redis.ts | 4 +++- src/queue/index.ts | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config/types.ts b/src/config/types.ts index 51b76262a..5f30d410c 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -19,6 +19,8 @@ export type Source = { host: string; port: number; pass: string; + db?: number; + prefix?: string; }; elasticsearch: { host: string; diff --git a/src/db/redis.ts b/src/db/redis.ts index 48e3f4e43..cebf2a10a 100644 --- a/src/db/redis.ts +++ b/src/db/redis.ts @@ -5,6 +5,8 @@ export default config.redis ? redis.createClient( config.redis.port, config.redis.host, { - auth_pass: config.redis.pass + auth_pass: config.redis.pass, + prefix: config.redis.prefix, + db: config.redis.db || 0 } ) : null; diff --git a/src/queue/index.ts b/src/queue/index.ts index eccb38b5e..83cebe247 100644 --- a/src/queue/index.ts +++ b/src/queue/index.ts @@ -16,8 +16,9 @@ function initializeQueue(name: string) { port: config.redis.port, host: config.redis.host, password: config.redis.pass, - db: 1 - } + db: config.redis.db || 0, + }, + prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue' } : null); }