protected function MemcachedProfilerStorage::getMemcached

Internal convenience method that returns the instance of the Memcached

Return value

Memcached

Throws

\RuntimeException

1 call to MemcachedProfilerStorage::getMemcached()
MemcachedProfilerStorage::appendValue in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php
Append data to an existing item on the memcache server

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php, line 35

Class

MemcachedProfilerStorage
Memcached Profiler Storage

Namespace

Symfony\Component\HttpKernel\Profiler

Code

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;
}