private function _connect($bailOnError = false)
    {
        $this->connected = $this->connect(
            $this->parameters['host'],
            $this->parameters['port'],
            ($this->parameters['timeout'] ?: 0)
        );

        if ($this->connected) {
            if ($this->parameters['auth']) {
                $this->auth($this->parameters['auth']);
            }

            if ($this->select($this->parameters['database'])) {
                // setup default options
                $this->setOption(\Redis::OPT_PREFIX, $this->parameters['prefix']);
                $this->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);

                return true;
            }
        } elseif (!$bailOnError) {
            // try to re-connect, but only once.
            usleep(1000);
            $this->_connect(true);
        }

        $error = $this->getLastError();
        $this->clearLastError();

        if ($this->logger) {
            $this->logger->err('Could not connect to redis server (' . $error . ')');
        }

        throw new PHPRedisCommunicationException('Could not connect to Redis: '.$error);
    }
private function _connect($bailOnError = false)
    {
        $this->connected = $this->connect(
            $this->parameters['host'],
            $this->parameters['port'],
            ($this->parameters['timeout'] ?: 0)
        );

        if ($this->connected) {
            if ($this->parameters['auth']) {
                $this->auth($this->parameters['auth']);
            }

            if ($this->select($this->parameters['database'])) {
                // setup default options
                $this->setOption(\Redis::OPT_PREFIX, $this->parameters['prefix']);
                $this->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);

                return true;
            }
        } elseif (!$bailOnError) {
            // try to re-connect, but only once.
            usleep(1000);
            $this->_connect(true);
        }

        $error = $this->getLastError();
        $this->clearLastError();

        if ($this->logger) {
            $this->logger->err('Could not connect to redis server (' . $error . ')');
        }

        throw new PHPRedisCommunicationException('Could not connect to Redis: '.$error);
    }
private function _connect ( $ bailOnError = false ) { $ this -> connected = $ this -> connect ( $ this -> parameters [ 'host' ] , $ this -> parameters [ 'port' ] , ( $ this -> parameters [ 'timeout' ] ? : 0 ) ) ; if ( $ this -> connected ) { if ( $ this -> parameters [ 'auth' ] ) { $ this -> auth ( $ this -> parameters [ 'auth' ] ) ; } if ( $ this -> select ( $ this -> parameters [ 'database' ] ) ) { // setup default options $ this -> setOption ( \ Redis :: OPT_PREFIX , $ this -> parameters [ 'prefix' ] ) ; $ this -> setOption ( \ Redis :: OPT_SERIALIZER , \ Redis :: SERIALIZER_PHP ) ; return true ; } } elseif ( ! $ bailOnError ) { // try to re-connect, but only once. usleep ( 1000 ) ; $ this -> _connect ( true ) ; } $ error = $ this -> getLastError ( ) ; $ this -> clearLastError ( ) ; if ( $ this -> logger ) { $ this -> logger -> err ( 'Could not connect to redis server (' . $ error . ')' ) ; } throw new PHPRedisCommunicationException ( 'Could not connect to Redis: ' . $ error ) ; }
handle connection management

@param boolean $bailOnError keeps track on connection retry

@return boolean
@throws PHPRedisCommunicationException If connection fails
handle connection management