protected function RedisProfilerStorage::getRedis

Internal convenience method that returns the instance of Redis.

Return value

Redis

3 calls to RedisProfilerStorage::getRedis()
RedisProfilerStorage::appendValue in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
Appends data to an existing item on the Redis server.
RedisProfilerStorage::getValue in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
Retrieves an item from the Redis server.
RedisProfilerStorage::setValue in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
Stores an item on the Redis server under the specified key.

File

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

Class

RedisProfilerStorage
RedisProfilerStorage stores profiling information in Redis.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function getRedis() {
  if (null === $this->redis) {
    if (!preg_match('#^redis://(?(?=\\[.*\\])\\[(.*)\\]|(.*)):(.*)$#', $this->dsn, $matches)) {
      throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The expected format is "redis://[host]:port".', $this->dsn));
    }
    $host = $matches[1] ?: $matches[2];
    $port = $matches[3];
    if (!extension_loaded('redis')) {
      throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.');
    }
    $redis = new Redis();
    $redis
      ->connect($host, $port);
    $redis
      ->setOption(self::REDIS_OPT_PREFIX, self::TOKEN_PREFIX);
    $this->redis = $redis;
  }
  return $this->redis;
}