Internal convenience method that returns the instance of the Memcached
Memcached
\RuntimeException
protected function getMemcached() {
if (null === $this->memcached) {
if (!preg_match('#^memcached://(?(?=\\[.*\\])\\[(.*)\\]|(.*)):(.*)$#', $this->dsn, $matches)) {
throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcached with an invalid dsn "%s". The expected format is "memcached://[host]:port".', $this->dsn));
}
$host = $matches[1] ?: $matches[2];
$port = $matches[3];
$memcached = new Memcached();
//disable compression to allow appending
$memcached
->setOption(Memcached::OPT_COMPRESSION, false);
$memcached
->addServer($host, $port);
$this->memcached = $memcached;
}
return $this->memcached;
}