Bravo3\Orm\Drivers\Redis\RedisDriver::clientCmd PHP Method

clientCmd() private method

A wrapper function to wrap Redis commands which go to Predis Client in order to replay them if server connection issues occur.
private clientCmd ( string $cmd, array | callable $params, integer $retry_iteration ) : mixed
$cmd string function to call against the Predis client
$params array | callable
$retry_iteration integer
return mixed
    private function clientCmd($cmd, $params, $retry_iteration = 0)
    {
        try {
            $delay = $this->calculateRetryDelay($retry_iteration);
            if ($delay > 0) {
                usleep($delay);
            }
            if (is_callable($params)) {
                return call_user_func([$this->client, $cmd], $params);
            } else {
                return call_user_func_array([$this->client, $cmd], $params);
            }
        } catch (\Exception $e) {
            if (++$retry_iteration <= $this->max_connection_retries) {
                return $this->clientCmd($cmd, $params, $retry_iteration);
            }
            throw $e;
        }
    }