protected function RedisProfilerStorage::getRedis

Internal convenience method that returns the instance of Redis.

Return value

Redis

Throws

\RuntimeException

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 206

Class

RedisProfilerStorage
RedisProfilerStorage stores profiling information in Redis.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function getRedis() {
  if (null === $this->redis) {
    $data = parse_url($this->dsn);
    if (false === $data || !isset($data['scheme']) || $data['scheme'] !== 'redis' || !isset($data['host']) || !isset($data['port'])) {
      throw new \RuntimeException(sprintf('Please check your configuration. You are trying to use Redis with an invalid dsn "%s". The minimal expected format is "redis://[host]:port".', $this->dsn));
    }
    if (!extension_loaded('redis')) {
      throw new \RuntimeException('RedisProfilerStorage requires that the redis extension is loaded.');
    }
    $redis = new Redis();
    $redis
      ->connect($data['host'], $data['port']);
    if (isset($data['path'])) {
      $redis
        ->select(substr($data['path'], 1));
    }
    if (isset($data['pass'])) {
      $redis
        ->auth($data['pass']);
    }
    $redis
      ->setOption(self::REDIS_OPT_PREFIX, self::TOKEN_PREFIX);
    $this->redis = $redis;
  }
  return $this->redis;
}