18 lines
578 B
TypeScript
18 lines
578 B
TypeScript
import { createClient, RedisClientType } from "redis";
|
|
|
|
export const pubClient: RedisClientType = createClient();
|
|
export const subClient: RedisClientType = pubClient.duplicate();
|
|
|
|
Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
|
|
console.log("Redis connected");
|
|
pubClient.keys("dispatchers*").then((keys) => {
|
|
if (!keys) return;
|
|
keys.forEach(async (key) => {
|
|
await pubClient.json.del(key);
|
|
});
|
|
});
|
|
});
|
|
|
|
pubClient.on("error", (err) => console.log("Redis Client Error", err));
|
|
subClient.on("error", (err) => console.log("Redis Client Error", err));
|