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
|
|
|
|
2021-03-22 23:54:09 -06:00
|
|
|
export function createConnection() {
|
2023-07-06 12:50:34 -06:00
|
|
|
let source = config.redis;
|
2023-11-05 07:00:19 -07:00
|
|
|
|
2022-06-24 04:22:19 -06:00
|
|
|
return new Redis({
|
2023-07-06 12:50:34 -06:00
|
|
|
port: source.port,
|
|
|
|
host: source.host,
|
|
|
|
family: source.family ?? 0,
|
|
|
|
password: source.pass,
|
|
|
|
username: source.user ?? "default",
|
|
|
|
keyPrefix: `${source.prefix}:`,
|
|
|
|
db: source.db || 0,
|
|
|
|
tls: source.tls,
|
2022-06-24 04:22:19 -06:00
|
|
|
});
|
2021-03-22 23:54:09 -06:00
|
|
|
}
|
2021-03-22 20:53:25 -06:00
|
|
|
|
2022-08-04 02:20:48 -06:00
|
|
|
export const subscriber = createConnection();
|
|
|
|
subscriber.subscribe(config.host);
|
2021-03-22 20:53:25 -06:00
|
|
|
|
2021-03-22 23:54:09 -06:00
|
|
|
export const redisClient = createConnection();
|