コード例 #1
0
ファイル: Redis.php プロジェクト: 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;
 }
コード例 #2
0
ファイル: RedisCluster.php プロジェクト: itkg/core
 /**
  * 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;
 }