jormungandr-bite/packages/backend/src/db/redis.ts

21 lines
522 B
TypeScript
Raw Normal View History

2023-01-12 21:40:33 -07:00
import Redis from "ioredis";
import config from "@/config/index.js";
2016-12-28 15:49:51 -07:00
export function createConnection() {
return new Redis({
port: config.redis.port,
host: config.redis.host,
family: config.redis.family ?? 0,
password: config.redis.pass,
username: config.redis.user ?? "default",
keyPrefix: `${config.redis.prefix}:`,
db: config.redis.db || 0,
tls: config.redis.tls,
});
}
2022-08-04 02:20:48 -06:00
export const subscriber = createConnection();
subscriber.subscribe(config.host);
export const redisClient = createConnection();