enhance: Redisをioredisに統一してIPv6サポート (#8869)
* Use ioredis, Supports IPv6 host https://github.com/misskey-dev/misskey/issues/8862 * Fix import * order * a * i * fix * flushdb * family * CHANGELOG * redis_version Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
1c2e2c4b06
commit
6f8e3fe366
9 changed files with 26 additions and 32 deletions
|
@ -192,12 +192,13 @@ export const db = new DataSource({
|
|||
synchronize: process.env.NODE_ENV === 'test',
|
||||
dropSchema: process.env.NODE_ENV === 'test',
|
||||
cache: !config.db.disableCache ? {
|
||||
type: 'redis',
|
||||
type: 'ioredis',
|
||||
options: {
|
||||
host: config.redis.host,
|
||||
port: config.redis.port,
|
||||
family: config.redis.family == null ? 0 : config.redis.family,
|
||||
password: config.redis.pass,
|
||||
prefix: `${config.redis.prefix}:query:`,
|
||||
keyPrefix: `${config.redis.prefix}:query:`,
|
||||
db: config.redis.db || 0,
|
||||
},
|
||||
} : false,
|
||||
|
@ -226,7 +227,7 @@ export async function initDb(force = false) {
|
|||
|
||||
export async function resetDb() {
|
||||
const reset = async () => {
|
||||
await redisClient.FLUSHDB();
|
||||
await redisClient.flushdb();
|
||||
const tables = await db.query(`SELECT relname AS "table"
|
||||
FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
||||
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import * as redis from 'redis';
|
||||
import Redis from 'ioredis';
|
||||
import config from '@/config/index.js';
|
||||
|
||||
export function createConnection() {
|
||||
return redis.createClient(
|
||||
config.redis.port,
|
||||
config.redis.host,
|
||||
{
|
||||
password: config.redis.pass,
|
||||
prefix: config.redis.prefix,
|
||||
db: config.redis.db || 0,
|
||||
}
|
||||
);
|
||||
return new Redis({
|
||||
port: config.redis.port,
|
||||
host: config.redis.host,
|
||||
family: config.redis.family == null ? 0 : config.redis.family,
|
||||
password: config.redis.pass,
|
||||
keyPrefix: `${config.redis.prefix}:`,
|
||||
db: config.redis.db || 0,
|
||||
});
|
||||
}
|
||||
|
||||
export const subsdcriber = createConnection();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue