You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +03:00
@ -232,10 +232,21 @@ export default class RedisClusterSlots<M extends RedisModules, S extends RedisSc
|
||||
return this.#nodeByUrl.get(url);
|
||||
}
|
||||
|
||||
async disconnect(): Promise<void> {
|
||||
await Promise.all(
|
||||
[...this.#nodeByUrl.values()].map(({ client }) => client.disconnect())
|
||||
);
|
||||
quit(): Promise<void> {
|
||||
return this.#destroy(client => client.quit());
|
||||
}
|
||||
|
||||
disconnect(): Promise<void> {
|
||||
return this.#destroy(client => client.disconnect());
|
||||
}
|
||||
|
||||
async #destroy(fn: (client: RedisClientType<M, S>) => Promise<unknown>): Promise<void> {
|
||||
const promises = [];
|
||||
for (const { client } of this.#nodeByUrl.values()) {
|
||||
promises.push(fn(client));
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
this.#nodeByUrl.clear();
|
||||
this.#slots.splice(0);
|
||||
|
@ -191,6 +191,10 @@ export default class RedisCluster<M extends RedisModules, S extends RedisScripts
|
||||
return this.#slots.getSlotMaster(slot);
|
||||
}
|
||||
|
||||
quit(): Promise<void> {
|
||||
return this.#slots.quit();
|
||||
}
|
||||
|
||||
disconnect(): Promise<void> {
|
||||
return this.#slots.disconnect();
|
||||
}
|
||||
|
Reference in New Issue
Block a user