Internal convenience method that returns the instance of Redis.
Redis
\RuntimeException
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;
}