diff --git a/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php b/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php index 00b809140..6d61c408c 100644 --- a/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php +++ b/src/Bundle/ChillMainBundle/Redis/RedisConnectionFactory.php @@ -14,7 +14,7 @@ namespace Chill\MainBundle\Redis; use RuntimeException; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class RedisConnectionFactory implements EventSubscriberInterface +final class RedisConnectionFactory implements EventSubscriberInterface { private string $host; @@ -29,12 +29,11 @@ class RedisConnectionFactory implements EventSubscriberInterface $this->host = $parameters['host']; $this->port = (int) $parameters['port']; $this->timeout = (int) $parameters['timeout']; + $this->redis = new ChillRedis(); } public function create() { - $this->redis = new ChillRedis(); - $result = $this->redis->connect($this->host, $this->port, $this->timeout); if (false === $result) { @@ -55,8 +54,6 @@ class RedisConnectionFactory implements EventSubscriberInterface public function onKernelFinishRequest() { - if (null !== $this->redis) { - $this->redis->close(); - } + $this->redis->close(); } }