コード例 #1
0
ファイル: Redis.php プロジェクト: atulhere/zendPractice
 /**
  * @return PredisClient|RedisExtensionClient
  *
  * @throws \RuntimeException
  */
 private function createClient()
 {
     if (class_exists('\\Redis')) {
         $client = new RedisExtensionClient();
         $client->connect($this->host);
         return $client;
     }
     if (class_exists('Predis\\Client')) {
         return new PredisClient(array('host' => $this->host, 'port' => $this->port));
     }
     throw new \RuntimeException('Neither the PHP Redis extension or Predis are installed');
 }
コード例 #2
0
ファイル: Redis.php プロジェクト: rmzamora/zenddiagnostics
 /**
  * @return PredisClient|RedisExtensionClient
  *
  * @throws \RedisException
  * @throws \RuntimeException
  */
 private function createClient()
 {
     if (class_exists('\\Redis')) {
         $client = new RedisExtensionClient();
         $client->connect($this->host, $this->port);
         if ($this->auth && false === $client->auth($this->auth)) {
             throw new \RedisException('Failed to AUTH connection');
         }
         return $client;
     }
     if (class_exists('Predis\\Client')) {
         $parameters = array('host' => $this->host, 'port' => $this->port);
         if ($this->auth) {
             $parameters['password'] = $this->auth;
         }
         return new PredisClient($parameters);
     }
     throw new \RuntimeException('Neither the PHP Redis extension or Predis are installed');
 }