(container: any, args: any[], options: any, callback?: Callback)
| 40 | } |
| 41 | |
| 42 | execute(container: any, args: any[], options: any, callback?: Callback) { |
| 43 | if (typeof this.numberOfKeys === "number") { |
| 44 | args.unshift(this.numberOfKeys); |
| 45 | } |
| 46 | if (this.keyPrefix) { |
| 47 | options.keyPrefix = this.keyPrefix; |
| 48 | } |
| 49 | if (this.readOnly) { |
| 50 | options.readOnly = true; |
| 51 | } |
| 52 | |
| 53 | const evalsha = new this.Command("evalsha", [this.sha, ...args], options); |
| 54 | |
| 55 | evalsha.promise = evalsha.promise.catch((err: Error) => { |
| 56 | if (err.message.indexOf("NOSCRIPT") === -1) { |
| 57 | throw err; |
| 58 | } |
| 59 | |
| 60 | // Resend the same custom evalsha command that gets transformed |
| 61 | // to an eval in case it's not loaded yet on the connection. |
| 62 | const resend = new this.Command("evalsha", [this.sha, ...args], options); |
| 63 | |
| 64 | const client = container.isPipeline ? container.redis : container; |
| 65 | return client.sendCommand(resend); |
| 66 | }); |
| 67 | |
| 68 | asCallback(evalsha.promise, callback); |
| 69 | return container.sendCommand(evalsha); |
| 70 | } |
| 71 | } |
no test coverage detected