host = $parameters['host']; $this->port = $parameters['port']; $this->timeout = $parameters['timeout']; } public function create() { $redis = $this->redis = new ChillRedis(); $result = $redis->connect($this->host, $this->port, $this->timeout); if (false === $result) { throw new RuntimeException('Could not connect to redis instance'); } return $redis; } public static function getSubscribedEvents(): array { return [ 'kernel.finish_request' => [ ['onKernelFinishRequest'], ], ]; } public function onKernelFinishRequest() { if (null !== $this->redis) { $this->redis->close(); } } }