Esempio n. 1
0
File: Redis.php Progetto: itkg/core
 /**
  * Connection getter
  *
  * @throws \RedisException
  * @return \Redis
  */
 public function getConnection()
 {
     if (null === $this->connection) {
         $this->connection = new \Redis();
         if (!$this->connection->pconnect($this->config['default']['host'], $this->config['default']['port'])) {
             throw new \RedisException('Unable to connect');
         }
     }
     return $this->connection;
 }
Esempio n. 2
0
 /**
  * Get slave connection
  * If connection is not initialized, we create a new one
  *
  * @return \Redis
  */
 public function getSlaveConnection()
 {
     if (null === $this->slaveConnection) {
         $this->slaveConnection = new \Redis();
         $this->slaveConnection->pconnect($this->config['slave']['HOST'], $this->config['slave']['PORT']);
     }
     return $this->slaveConnection;
 }