function __construct($url) { try { list($user, $passwd, $host, $port, $db) = self::parseRedisUrl($url); $this->_redis = new Client(array('host' => $host, 'port' => $port)); } catch (\Exception $e) { throw new RedisBundleException($e); } try { $this->_redis->connect(); $this->_redis->select($db); } catch (\Predis\Connection\ConnectionException $e) { throw new RedisBundleException($e); } }
/** * Returns a new client instance. * * @return Client */ protected function getClient() { $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'iterable_multibulk' => true, 'read_write_timeout' => 2); $client = new Client($parameters, REDIS_SERVER_VERSION); $client->connect(); $client->select(REDIS_SERVER_DBNUM); $client->flushdb(); return $client; }
/** @BeforeFeature */ public static function setupFeature(FeatureEvent $event) { try { $redis = new Client('tcp://127.0.0.1:6379'); $redis->select(15); $redis->flushdb(); } catch (\Exception $e) { echo "Redis Server is needed to test features!" . PHP_EOL; throw $e; } }
/** * Returns a new client instance. * * @param Boolean $connect Flush selected database before returning the client. * @return Client */ protected function getClient($flushdb = true) { $profile = $this->getProfile(); if (!$profile->supportsCommand($id = $this->getExpectedId())) { $this->markTestSkipped("The profile {$profile->getVersion()} does not support command {$id}"); } $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT); $options = array('profile' => $profile); $client = new Client($parameters, $options); $client->connect(); $client->select(REDIS_SERVER_DBNUM); if ($flushdb) { $client->flushdb(); } return $client; }
public function __construct() { $this->redis = new Client(array('host' => self::$host, 'port' => self::$port, 'database' => self::$port)); $this->redis->select(self::$db); }
public function createClient() { $client = new Predis\Client(); $client->select(10); return $client; }
/** * @inheritdoc */ public function select($database) { parent::select($database); $this->server->setDatabaseIndex($database); }
public function select($database) { return $this->_client->select($database); }