示例#1
0
 public static function createConnection(array $additional = array())
 {
     $serverProfile = Predis\Profiles\ServerProfile::get(self::SERVER_VERSION);
     $connection = new Predis\Client(RC::getConnectionArguments($additional), $serverProfile);
     $connection->connect();
     $connection->select(RC::DEFAULT_DATABASE);
     return $connection;
 }
示例#2
0
 function testStreamConnection_ReadTimeout()
 {
     $timeout = 1;
     $args = array_merge(RC::getConnectionArguments(), array('read_write_timeout' => $timeout));
     $cmdFake = Predis\Profiles\ServerProfile::getDefault()->createCommand('ping');
     $connection = new Predis\Network\StreamConnection(new Predis\ConnectionParameters($args));
     $expectedMessage = 'Error while reading line from the server';
     $start = time();
     RC::testForCommunicationException($this, $expectedMessage, function () use($connection, $cmdFake) {
         $connection->readResponse($cmdFake);
     });
     $this->assertEquals((double) (time() - $start), $timeout, '', 1);
 }