public function getMemcacheConnection(array $options = [])
    {
        $options = array_replace(['host' => 'localhost', 'port' => 11211], $options);
        if (null !== $cache = $this->getConnection('memcache', $options)) {
            return $cache;
        }

        if (!extension_loaded('memcache')) {
            throw new RuntimeException('The Memcache cache requires the Memcache extension.');
        }

        $memcache = new \Memcache();
        $memcache->addServer($options['host'], $options['port']);

        $key = sprintf("%s:%s", $options['host'], $options['port']);
        $stats = @$memcache->getExtendedStats();

        if (!isset($stats[$key]) || false === $stats[$key]) {
            throw new RuntimeException(sprintf("Memcache instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }

        return $this->setConnection('memcache', $options, $memcache);
    }
public function getMemcacheConnection(array $options = [])
    {
        $options = array_replace(['host' => 'localhost', 'port' => 11211], $options);
        if (null !== $cache = $this->getConnection('memcache', $options)) {
            return $cache;
        }

        if (!extension_loaded('memcache')) {
            throw new RuntimeException('The Memcache cache requires the Memcache extension.');
        }

        $memcache = new \Memcache();
        $memcache->addServer($options['host'], $options['port']);

        $key = sprintf("%s:%s", $options['host'], $options['port']);
        $stats = @$memcache->getExtendedStats();

        if (!isset($stats[$key]) || false === $stats[$key]) {
            throw new RuntimeException(sprintf("Memcache instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }

        return $this->setConnection('memcache', $options, $memcache);
    }
public function getMemcacheConnection ( array $ options = [ ] ) { $ options = array_replace ( [ 'host' => 'localhost' , 'port' => 11211 ] , $ options ) ; if ( null !== $ cache = $ this -> getConnection ( 'memcache' , $ options ) ) { return $ cache ; } if ( ! extension_loaded ( 'memcache' ) ) { throw new RuntimeException ( 'The Memcache cache requires the Memcache extension.' ) ; } $ memcache = new \ Memcache ( ) ; $ memcache -> addServer ( $ options [ 'host' ] , $ options [ 'port' ] ) ; $ key = sprintf ( "%s:%s" , $ options [ 'host' ] , $ options [ 'port' ] ) ; $ stats = @ $ memcache -> getExtendedStats ( ) ; if ( ! isset ( $ stats [ $ key ] ) || false === $ stats [ $ key ] ) { throw new RuntimeException ( sprintf ( "Memcache instance with host '%s' and port '%s' is not reachable." , $ options [ 'host' ] , $ options [ 'port' ] ) ) ; } return $ this -> setConnection ( 'memcache' , $ options , $ memcache ) ; }
Returns a Memcache connection.

@param array $options Available options are 'host' and 'port'

@return \Memcache

@throws RuntimeException
Returns a Memcache connection .