PHPDaemon\Clients\Redis\Pool::__call PHP Method

__call() public method

Magic __call Example: $redis->lpush('mylist', microtime(true));
public __call ( $cmd, array $args ) : void
$args array Arguments
return void
    public function __call($cmd, $args)
    {
        $cb = null;
        for ($i = sizeof($args) - 1; $i >= 0; --$i) {
            $a = $args[$i];
            if ((is_array($a) || is_object($a)) && is_callable($a)) {
                $cb = CallbackWrapper::wrap($a);
                $args = array_slice($args, 0, $i);
                break;
            } elseif ($a !== null) {
                break;
            }
        }
        reset($args);
        $cmd = strtoupper($cmd);
        if ($this->sendSubCommand($cmd, $args, $cb)) {
            return;
        }
        if ($cmd === 'SENTINEL' || !isset($this->config->sentinelmaster->value)) {
            $this->sendCommand(null, $cmd, $args, $cb);
            return;
        }
        if ($this->currentMasterAddr !== null) {
            $this->sendCommand($this->currentMasterAddr, $cmd, $args, $cb);
            return;
        }
        $this->sentinel('get-master-addr-by-name', $this->config->sentinelmaster->value, function ($redis) use($cmd, $args, $cb) {
            $this->currentMasterAddr = 'tcp://' . $redis->result[0] . ':' . $redis->result[1];
            $this->sendCommand($this->currentMasterAddr, $cmd, $args, $cb);
        });
    }