src/Connection.php
public function executeCommand($name, $params = [])
    {
        $this->open();

        $params = array_merge(explode(' ', $name), $params);
        $command = '';
        $paramsCount = 0;
        foreach ($params as $arg) {
            if ($arg === null) {
                continue;
            }

            $paramsCount++;
            $command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n";
        }
        $command = '*' . $paramsCount . "\r\n" . $command;

        \Yii::trace("Executing Redis Command: {$name}", __METHOD__);
        if ($this->retries > 0) {
            $tries = $this->retries;
            while ($tries-- > 0) {
                try {
                    return $this->sendCommandInternal($command, $params);
                } catch (SocketException $e) {
                    \Yii::error($e, __METHOD__);
                    // backup retries, fail on commands that fail inside here
                    $retries = $this->retries;
                    $this->retries = 0;
                    $this->close();
                    $this->open();
                    $this->retries = $retries;
                }
            }
        }
        return $this->sendCommandInternal($command, $params);
    }
public function executeCommand($name, $params = [])
    {
        $this->open();

        $params = array_merge(explode(' ', $name), $params);
        $command = '';
        $paramsCount = 0;
        foreach ($params as $arg) {
            if ($arg === null) {
                continue;
            }

            $paramsCount++;
            $command .= '$' . mb_strlen($arg, '8bit') . "\r\n" . $arg . "\r\n";
        }
        $command = '*' . $paramsCount . "\r\n" . $command;

        \Yii::trace("Executing Redis Command: {$name}", __METHOD__);
        if ($this->retries > 0) {
            $tries = $this->retries;
            while ($tries-- > 0) {
                try {
                    return $this->sendCommandInternal($command, $params);
                } catch (SocketException $e) {
                    \Yii::error($e, __METHOD__);
                    // backup retries, fail on commands that fail inside here
                    $retries = $this->retries;
                    $this->retries = 0;
                    $this->close();
                    $this->open();
                    $this->retries = $retries;
                }
            }
        }
        return $this->sendCommandInternal($command, $params);
    }
public function executeCommand ( $ name , $ params = [ ] ) { $ this -> open ( ) ; $ params = array_merge ( explode ( ' ' , $ name ) , $ params ) ; $ command = '' ; $ paramsCount = 0 ; foreach ( $ params as $ arg ) { if ( $ arg === null ) { continue ; } $ paramsCount ++ ; $ command .= '$' . mb_strlen ( $ arg , '8bit' ) . "\r\n" . $ arg . "\r\n" ; } $ command = '*' . $ paramsCount . "\r\n" . $ command ; \ Yii :: trace ( "Executing Redis Command: {$name}" , __METHOD__ ) ; if ( $ this -> retries > 0 ) { $ tries = $ this -> retries ; while ( $ tries -- > 0 ) { try { return $ this -> sendCommandInternal ( $ command , $ params ) ; } catch ( SocketException $ e ) { \ Yii :: error ( $ e , __METHOD__ ) ; // backup retries, fail on commands that fail inside here $ retries = $ this -> retries ; $ this -> retries = 0 ; $ this -> close ( ) ; $ this -> open ( ) ; $ this -> retries = $ retries ; } } } return $ this -> sendCommandInternal ( $ command , $ params ) ; }
Executes a redis command.
For a list of available commands and their parameters see http://redis.io/commands.

The params array should contain the params separated by white space, e.g. to execute
`SET mykey somevalue NX` call the following:

```php
$redis->executeCommand('SET', ['mykey', 'somevalue', 'NX']);
```

@param string $name the name of the command
@param array $params list of parameters for the command
@return array|bool|null|string Dependent on the executed command this method
will return different data types:

- `true` for commands that return "status reply" with the message `'OK'` or `'PONG'`.
- `string` for commands that return "status reply" that does not have the message `OK` (since version 2.0.1).
- `string` for commands that return "integer reply"
as the value is in the range of a signed 64 bit integer.
- `string` or `null` for commands that return "bulk reply".
- `array` for commands that return "Multi-bulk replies".

See [redis protocol description](http://redis.io/topics/protocol)
for details on the mentioned reply types.
@throws Exception for commands that return [error reply](http://redis.io/topics/protocol#error-reply).
Executes a redis command . For a list of available commands and their parameters see http : // redis . io / commands .