Predis\Connection\NodeConnectionInterface::addConnectCommand PHP Method

addConnectCommand() public method

Pushes the given command into a queue of commands executed when establishing the actual connection to Redis.
public addConnectCommand ( Predis\Command\CommandInterface $command )
$command Predis\Command\CommandInterface Instance of a Redis command.
    public function addConnectCommand(CommandInterface $command);

Usage Example

Example #1
0
 /**
  * Prepares a connection instance after its initialization.
  *
  * @param NodeConnectionInterface $connection Connection instance.
  */
 protected function prepareConnection(NodeConnectionInterface $connection)
 {
     $parameters = $connection->getParameters();
     if (isset($parameters->password)) {
         $connection->addConnectCommand(new RawCommand(array('AUTH', $parameters->password)));
     }
     if (isset($parameters->database)) {
         $connection->addConnectCommand(new RawCommand(array('SELECT', $parameters->database)));
     }
 }