From 3b4976edaa775eaf30d1d0d61a9c426ec7253e96 Mon Sep 17 00:00:00 2001 From: leibale Date: Thu, 29 Jul 2021 09:33:14 -0400 Subject: [PATCH] use the same Multi with duplicated clients --- lib/client.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/client.ts b/lib/client.ts index 14cbdff274..087d643225 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -83,19 +83,22 @@ export default class RedisClient(options?: RedisClientOptions): RedisClientType { - return new (extendWithModulesAndScripts({ + const Client = (extendWithModulesAndScripts({ BaseClass: RedisClient, modules: options?.modules, modulesCommandsExecutor: RedisClient.commandsExecutor, scripts: options?.scripts, scriptsExecutor: RedisClient.#scriptsExecutor - }))(options); + })); + + Client.prototype.Multi = RedisMultiCommand.extend(options); + + return new Client(options); } readonly #options?: RedisClientOptions; readonly #socket: RedisSocket; readonly #queue: RedisCommandsQueue; - readonly #Multi: new (...args: ConstructorParameters) => RedisMultiCommandType; readonly #v4: Record = {}; #selectedDB = 0; @@ -120,7 +123,6 @@ export default class RedisClient) => Promise) { - - } - async executeScript(script: RedisLuaScript, args: Array, options?: ClientCommandOptions): Promise> { try { return await this.#sendCommand([ @@ -349,7 +347,8 @@ export default class RedisClient { - return new this.#Multi( + // Multi is attached in `create` + return new (this as any).Multi( this.#multiExecutor.bind(this), this.#options );