From bb0da10d739ae68fa93723d974fd040e1d24ee5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Fri, 5 Jan 2024 19:15:04 +0900 Subject: [PATCH] =?UTF-8?q?enhance(PostgreSQL):=20DB=E3=81=AE=E3=82=AF?= =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=83=BC=E3=81=AE=E3=82=AD=E3=83=A3=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E3=81=AB=E4=BD=BF=E3=82=8F=E3=82=8C=E3=82=8B?= =?UTF-8?q?Redis=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=E5=88=86=E3=81=91?= =?UTF-8?q?=E3=82=8B=20(MisskeyIO#322)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/config.ts | 3 +++ packages/backend/src/postgres.ts | 8 ++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index f20093e802..9753b3c6b0 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -46,6 +46,7 @@ type Source = { pass: string; }[]; redis: RedisOptionsSource; + redisForDatabaseCache?: RedisOptionsSource; redisForPubsub?: RedisOptionsSource; redisForJobQueue?: RedisOptionsSource; redisForSystemQueue?: RedisOptionsSource; @@ -176,6 +177,7 @@ export type Config = { externalMediaProxyEnabled: boolean; videoThumbnailGenerator: string | null; redis: RedisOptions & RedisOptionsSource; + redisForDatabaseCache: RedisOptions & RedisOptionsSource; redisForPubsub: RedisOptions & RedisOptionsSource; redisForSystemQueue: RedisOptions & RedisOptionsSource; redisForEndedPollNotificationQueue: RedisOptions & RedisOptionsSource; @@ -251,6 +253,7 @@ export function loadConfig(): Config { dbSlaves: config.dbSlaves, meilisearch: config.meilisearch, redis, + redisForDatabaseCache: config.redisForDatabaseCache ? convertRedisOptions(config.redisForDatabaseCache, host) : redis, redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, host) : redis, redisForSystemQueue: config.redisForSystemQueue ? convertRedisOptions(config.redisForSystemQueue, host) : redisForJobQueue, redisForEndedPollNotificationQueue: config.redisForEndedPollNotificationQueue ? convertRedisOptions(config.redisForEndedPollNotificationQueue, host) : redisForJobQueue, diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index a60875cbaa..fa5ce55da3 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -230,12 +230,8 @@ export function createPostgresDataSource(config: Config) { cache: !config.db.disableCache && process.env.NODE_ENV !== 'test' ? { // dbをcloseしても何故かredisのコネクションが内部的に残り続けるようで、テストの際に支障が出るため無効にする(キャッシュも含めてテストしたいため本当は有効にしたいが...) type: 'ioredis', options: { - host: config.redis.host, - port: config.redis.port, - family: config.redis.family ?? 0, - password: config.redis.pass, - keyPrefix: `${config.redis.prefix}:query:`, - db: config.redis.db ?? 0, + ...config.redisForDatabaseCache, + keyPrefix: `${config.redisForDatabaseCache.prefix}:query:`, }, } : false, logging: log,