protected function MemcacheProfilerStorage::getMemcache

Internal convenience method that returns the instance of the Memcache

Return value

Memcache

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

File

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

Class

MemcacheProfilerStorage
Memcache Profiler Storage

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function getMemcache() {
  if (null === $this->memcache) {
    if (!preg_match('#^memcache://(?(?=\\[.*\\])\\[(.*)\\]|(.*)):(.*)$#', $this->dsn, $matches)) {
      throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Memcache with an invalid dsn "%s". The expected format is "memcache://[host]:port".', $this->dsn));
    }
    $host = $matches[1] ?: $matches[2];
    $port = $matches[3];
    $memcache = new Memcache();
    $memcache
      ->addServer($host, $port);
    $this->memcache = $memcache;
  }
  return $this->memcache;
}