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

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

        $memcached = new \Memcached();
        $memcached->addServer($options['host'], $options['port']);
        $memcached->getStats();

        if (\Memcached::RES_SUCCESS !== $memcached->getResultCode()) {
            throw new RuntimeException(sprintf("Memcached instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }

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

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

        $memcached = new \Memcached();
        $memcached->addServer($options['host'], $options['port']);
        $memcached->getStats();

        if (\Memcached::RES_SUCCESS !== $memcached->getResultCode()) {
            throw new RuntimeException(sprintf("Memcached instance with host '%s' and port '%s' is not reachable.", $options['host'], $options['port']));
        }

        return $this->setConnection('memcached', $options, $memcached);
    }
public function getMemcachedConnection ( array $ options = [ ] ) { $ options = array_replace ( [ 'host' => 'localhost' , 'port' => 11211 ] , $ options ) ; if ( null !== $ cache = $ this -> getConnection ( 'memcached' , $ options ) ) { return $ cache ; } if ( ! extension_loaded ( 'memcached' ) ) { throw new RuntimeException ( 'The Memcached cache requires the Memcached extension.' ) ; } $ memcached = new \ Memcached ( ) ; $ memcached -> addServer ( $ options [ 'host' ] , $ options [ 'port' ] ) ; $ memcached -> getStats ( ) ; if ( \ Memcached :: RES_SUCCESS !== $ memcached -> getResultCode ( ) ) { throw new RuntimeException ( sprintf ( "Memcached instance with host '%s' and port '%s' is not reachable." , $ options [ 'host' ] , $ options [ 'port' ] ) ) ; } return $ this -> setConnection ( 'memcached' , $ options , $ memcached ) ; }
Returns a Memcached connection.

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

@return \Memcached

@throws RuntimeException
Returns a Memcached connection .