| 299 | export type MonitorCallback<TYPE_MAPPING extends TypeMapping = TypeMapping> = (reply: ReplyWithTypeMapping<SimpleStringReply, TYPE_MAPPING>) => unknown; |
| 300 | |
| 301 | export default class RedisClient< |
| 302 | M extends RedisModules, |
| 303 | F extends RedisFunctions, |
| 304 | S extends RedisScripts, |
| 305 | RESP extends RespVersions, |
| 306 | TYPE_MAPPING extends TypeMapping |
| 307 | > extends EventEmitter { |
| 308 | static #createCommand(command: Command, resp: RespVersions) { |
| 309 | const transformReply = getTransformReply(command, resp); |
| 310 | |
| 311 | return async function (this: ProxyClient, ...args: Array<unknown>) { |
| 312 | const parser = new BasicCommandParser(this._self._keyPrefix); |
| 313 | command.parseCommand(parser, ...args); |
| 314 | |
| 315 | return this._self._executeCommand(command, parser, this._commandOptions, transformReply); |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | static #createModuleCommand(command: Command, resp: RespVersions) { |
| 320 | const transformReply = getTransformReply(command, resp); |
| 321 | |
| 322 | return async function (this: NamespaceProxyClient, ...args: Array<unknown>) { |
| 323 | const parser = new BasicCommandParser(this._self._keyPrefix); |
| 324 | command.parseCommand(parser, ...args); |
| 325 | |
| 326 | return this._self._executeCommand(command, parser, this._self._commandOptions, transformReply); |
| 327 | }; |
| 328 | } |
| 329 | |
| 330 | static #createFunctionCommand(name: string, fn: RedisFunction, resp: RespVersions) { |
| 331 | const prefix = functionArgumentsPrefix(name, fn); |
| 332 | const transformReply = getTransformReply(fn, resp); |
| 333 | |
| 334 | return async function (this: NamespaceProxyClient, ...args: Array<unknown>) { |
| 335 | const parser = new BasicCommandParser(this._self._keyPrefix); |
| 336 | parser.push(...prefix); |
| 337 | fn.parseCommand(parser, ...args); |
| 338 | |
| 339 | return this._self._executeCommand(fn, parser, this._self._commandOptions, transformReply); |
| 340 | }; |
| 341 | } |
| 342 | |
| 343 | static #createScriptCommand(script: RedisScript, resp: RespVersions) { |
| 344 | const prefix = scriptArgumentsPrefix(script); |
| 345 | const transformReply = getTransformReply(script, resp); |
| 346 | |
| 347 | return async function (this: ProxyClient, ...args: Array<unknown>) { |
| 348 | const parser = new BasicCommandParser(this._self._keyPrefix); |
| 349 | parser.push(...prefix); |
| 350 | script.parseCommand(parser, ...args) |
| 351 | |
| 352 | return this._executeScript(script, parser, this._commandOptions, transformReply); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 357 | static #SingleEntryCache = new SingleEntryCache<any, any>() |
| 358 |
nothing calls this directly
no test coverage detected