/** * @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'); }
/** * @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'); }