You are here

protected function MemcacheProfilerStorage::getMemcache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Profiler/MemcacheProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage::getMemcache()

Internal convenience method that returns the instance of the Memcache.

Return value

\Memcache

Throws

\RuntimeException

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

File

vendor/symfony/http-kernel/Profiler/MemcacheProfilerStorage.php, line 33

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