* Attach all lua scripts in a given directory to a client instance * @param client - redis client to attach script to * @param pathname - the path to the directory containing the scripts
(client, pathname, cache)
| 397 | * @param pathname - the path to the directory containing the scripts |
| 398 | */ |
| 399 | async load(client, pathname, cache) { |
| 400 | let paths = this.clientScripts.get(client); |
| 401 | if (!paths) { |
| 402 | paths = new Set(); |
| 403 | this.clientScripts.set(client, paths); |
| 404 | } |
| 405 | if (!paths.has(pathname)) { |
| 406 | paths.add(pathname); |
| 407 | const scripts = await this.loadScripts( |
| 408 | pathname, |
| 409 | cache ? cache : new Map() |
| 410 | ); |
| 411 | scripts.forEach(command => { |
| 412 | // Only define the command if not already defined |
| 413 | if (!client[command.name]) { |
| 414 | client.defineCommand(command.name, command.options); |
| 415 | } |
| 416 | }); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Clears the command cache |
nothing calls this directly
no test coverage detected