pass redis config as-is to postgres cache

also, explicitly state that `path` is a valid config option for
redis (tells `ioredis` to connect via UNIX socked instead of TCP
socket)
This commit is contained in:
dakkar 2024-07-21 11:02:46 +01:00
parent 69bdbf22b3
commit 6e1e3bc0ea
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';
type RedisOptionsSource = Partial<RedisOptions> & {
host: string;
port: number;
host?: string;
port?: number;
family?: number;
path?: string,
pass: string;
db?: number;
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のコネクションが内部的に残り続けるようで、テストの際に支障が出るため無効にする(キャッシュも含めてテストしたいため本当は有効にしたいが...)
type: 'ioredis',
options: {
host: config.redis.host,
port: config.redis.port,
family: config.redis.family ?? 0,
password: config.redis.pass,
...config.redis,
keyPrefix: `${config.redis.prefix}:query:`,
db: config.redis.db ?? 0,
},
} : false,
logging: log,