Exemplo n.º 1
0
 public function __construct(array $configs)
 {
     foreach ($configs as $name => $config) {
         $check = new Redis($config['host'], $config['port']);
         $check->setLabel(sprintf('Redis "%s"', $name));
         $this->checks[sprintf('redis_%s', $name)] = $check;
     }
 }
Exemplo n.º 2
0
 public function testRedis()
 {
     $check = new Redis();
     $result = $check->check();
     $this->assertInstanceOf('ZendDiagnostics\\Result\\Success', $result);
     $check = new Redis('127.0.0.250', 9999);
     $this->setExpectedException('Predis\\Connection\\ConnectionException');
     $check->check();
 }
Exemplo n.º 3
0
 /**
  * @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');
 }
Exemplo n.º 4
0
 /**
  * @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');
 }