plugins/kvdb/redis_php/redis_php.kvdriver.php
protected function _connect() {

        // A host is needed
        if (! isset($this->_profile['host'])) {
            throw new jException(
                'jelix~kvstore.error.no.host', $this->_profileName);
        }

        // A port is needed as well
        if (! isset($this->_profile['port'])) {
            throw new jException(
                'jelix~kvstore.error.no.port', $this->_profileName);
        }

        if (isset($this->_profile['key_prefix'])) {
            $this->key_prefix = $this->_profile['key_prefix'];
        }

        if ($this->key_prefix && isset($this->_profile['key_prefix_flush_method'])) {
            if (in_array($this->_profile['key_prefix_flush_method'],
                         array('direct', 'jkvdbredisworker', 'event'))) {
                $this->key_prefix_flush_method = $this->_profile['key_prefix_flush_method'];
            }
        }

        // OK, let's connect now
        $cnx = new \PhpRedis\Redis($this->_profile['host'], $this->_profile['port']);

        if (isset($this->_profile['db']) && intval($this->_profile['db']) != 0) {
            $cnx->select_db($this->_profile['db']);
        }
        return $cnx;
    }
protected function _connect() {

        // A host is needed
        if (! isset($this->_profile['host'])) {
            throw new jException(
                'jelix~kvstore.error.no.host', $this->_profileName);
        }

        // A port is needed as well
        if (! isset($this->_profile['port'])) {
            throw new jException(
                'jelix~kvstore.error.no.port', $this->_profileName);
        }

        if (isset($this->_profile['key_prefix'])) {
            $this->key_prefix = $this->_profile['key_prefix'];
        }

        if ($this->key_prefix && isset($this->_profile['key_prefix_flush_method'])) {
            if (in_array($this->_profile['key_prefix_flush_method'],
                         array('direct', 'jkvdbredisworker', 'event'))) {
                $this->key_prefix_flush_method = $this->_profile['key_prefix_flush_method'];
            }
        }

        // OK, let's connect now
        $cnx = new \PhpRedis\Redis($this->_profile['host'], $this->_profile['port']);

        if (isset($this->_profile['db']) && intval($this->_profile['db']) != 0) {
            $cnx->select_db($this->_profile['db']);
        }
        return $cnx;
    }
protected function _connect ( ) { // A host is needed if ( ! isset ( $ this -> _profile [ 'host' ] ) ) { throw new jException ( 'jelix~kvstore.error.no.host' , $ this -> _profileName ) ; } // A port is needed as well if ( ! isset ( $ this -> _profile [ 'port' ] ) ) { throw new jException ( 'jelix~kvstore.error.no.port' , $ this -> _profileName ) ; } if ( isset ( $ this -> _profile [ 'key_prefix' ] ) ) { $ this -> key_prefix = $ this -> _profile [ 'key_prefix' ] ; } if ( $ this -> key_prefix && isset ( $ this -> _profile [ 'key_prefix_flush_method' ] ) ) { if ( in_array ( $ this -> _profile [ 'key_prefix_flush_method' ] , array ( 'direct' , 'jkvdbredisworker' , 'event' ) ) ) { $ this -> key_prefix_flush_method = $ this -> _profile [ 'key_prefix_flush_method' ] ; } } // OK, let's connect now $ cnx = new \ PhpRedis \ Redis ( $ this -> _profile [ 'host' ] , $ this -> _profile [ 'port' ] ) ; if ( isset ( $ this -> _profile [ 'db' ] ) && intval ( $ this -> _profile [ 'db' ] ) != 0 ) { $ cnx -> select_db ( $ this -> _profile [ 'db' ] ) ; } return $ cnx ; }
Connects to the redis server
@return \PhpRedis\Redis object
@throws jException
Connects to the redis server