You are here

protected function MemcachedProfilerStorage::getMemcached in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Profiler/MemcachedProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\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 vendor/symfony/http-kernel/Profiler/MemcachedProfilerStorage.php
Append data to an existing item on the memcache server.

File

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

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