@@ -47,6 +47,7 @@ It enables you to set and query its data or use its PubSub topics to react to in
4747 * [ RedisClient] ( #redisclient )
4848 * [ __ construct()] ( #__construct )
4949 * [ __ call()] ( #__call )
50+ * [ callAsync()] ( #callasync )
5051 * [ end()] ( #end )
5152 * [ close()] ( #close )
5253 * [ error event] ( #error-event )
@@ -124,7 +125,8 @@ Each method call matches the respective [Redis command](https://redis.io/command
124125For example, the ` $redis->get() ` method will invoke the [ ` GET ` command] ( https://redis.io/commands/get ) .
125126
126127All [ Redis commands] ( https://redis.io/commands ) are automatically available as
127- public methods via the magic [ ` __call() ` method] ( #__call ) .
128+ public methods via the magic [ ` __call() ` method] ( #__call ) or through the more
129+ explicit [ ` callAsync() ` method] .
128130Listing all available commands is out of scope here, please refer to the
129131[ Redis command reference] ( https://redis.io/commands ) .
130132
@@ -432,6 +434,8 @@ $redis->get($key)->then(function (?string $value) {
432434
433435All [ Redis commands] ( https://redis.io/commands ) are automatically available as
434436public methods via this magic ` __call() ` method.
437+ Note that some static analysis tools may not understand this magic method, so
438+ you may also the [ ` callAsync() ` method] ( #callasync ) as a more explicit alternative.
435439Listing all available commands is out of scope here, please refer to the
436440[ Redis command reference] ( https://redis.io/commands ) .
437441
@@ -445,6 +449,43 @@ Each of these commands supports async operation and returns a [Promise](#promise
445449that eventually * fulfills* with its * results* on success or * rejects* with an
446450` Exception ` on error. See also [ promises] ( #promises ) for more details.
447451
452+ #### callAsync()
453+
454+ The ` callAsync(string $command, string ...$args): PromiseInterface<mixed> ` method can be used to
455+ invoke a Redis command.
456+
457+ ``` php
458+ $redis->callAsync('GET', 'name')->then(function (?string $name): void {
459+ echo 'Name: ' . ($name ?? 'Unknown') . PHP_EOL;
460+ }, function (Throwable $e): void {
461+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
462+ });
463+ ```
464+
465+ The ` string $command ` parameter can be any valid Redis command. All
466+ [ Redis commands] ( https://redis.io/commands/ ) are available through this
467+ method. As an alternative, you may also use the magic
468+ [ ` __call() ` method] ( #__call ) , but note that not all static analysis tools
469+ may understand this magic method. Listing all available commands is out
470+ of scope here, please refer to the
471+ [ Redis command reference] ( https://redis.io/commands ) .
472+
473+ The optional ` string ...$args ` parameter can be used to pass any
474+ additional arguments to the Redis command. Some commands may require or
475+ support additional arguments that this method will simply forward as is.
476+ Internally, Redis requires all arguments to be coerced to ` string ` values,
477+ but you may also rely on PHP's type-juggling semantics and pass ` int ` or
478+ ` float ` values:
479+
480+ ``` php
481+ $redis->callAsync('SET', 'name', 'Alice', 'EX', 600);
482+ ```
483+
484+ This method supports async operation and returns a [ Promise] ( #promises )
485+ that eventually * fulfills* with its * results* on success or * rejects*
486+ with an ` Exception ` on error. See also [ promises] ( #promises ) for more
487+ details.
488+
448489#### end()
449490
450491The ` end():void ` method can be used to
0 commit comments