merge: pass redis config as-is to postgres cache (!577)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/577

Approved-by: Tess K <me@thvxl.se>
Approved-by: Marie <marie@kaifa.ch>
This commit is contained in:
dakkar 2024-08-02 18:41:29 +00:00
commit 41e32e792a
2 changed files with 4 additions and 7 deletions

View File

@ -12,9 +12,10 @@ import * as Sentry from '@sentry/node';
import type { RedisOptions } from 'ioredis'; import type { RedisOptions } from 'ioredis';
type RedisOptionsSource = Partial<RedisOptions> & { type RedisOptionsSource = Partial<RedisOptions> & {
host: string; host?: string;
port: number; port?: number;
family?: number; family?: number;
path?: string,
pass: string; pass: string;
db?: number; db?: number;
prefix?: string; prefix?: string;

View File

@ -236,12 +236,8 @@ export function createPostgresDataSource(config: Config) {
cache: !config.db.disableCache && process.env.NODE_ENV !== 'test' ? { // dbをcloseしても何故かredisのコネクションが内部的に残り続けるようで、テストの際に支障が出るため無効にする(キャッシュも含めてテストしたいため本当は有効にしたいが...) cache: !config.db.disableCache && process.env.NODE_ENV !== 'test' ? { // dbをcloseしても何故かredisのコネクションが内部的に残り続けるようで、テストの際に支障が出るため無効にする(キャッシュも含めてテストしたいため本当は有効にしたいが...)
type: 'ioredis', type: 'ioredis',
options: { options: {
host: config.redis.host, ...config.redis,
port: config.redis.port,
family: config.redis.family ?? 0,
password: config.redis.pass,
keyPrefix: `${config.redis.prefix}:query:`, keyPrefix: `${config.redis.prefix}:query:`,
db: config.redis.db ?? 0,
}, },
} : false, } : false,
logging: log, logging: log,