From c67a4601ace3c75b81872769948d32e4dfba0429 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 30 Nov 2021 16:34:11 +0100 Subject: [PATCH 1/2] Allow changing the redis session TTL at runtime --- .../Session/Storage/Handler/RedisSessionHandler.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index b07a955da3f5d..312af25b10802 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -50,7 +50,7 @@ public function __construct(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInter $this->redis = $redis; $this->prefix = $options['prefix'] ?? 'sf_s'; - $this->ttl = $options['ttl'] ?? null; + $this->setTtl($options['ttl'] ?? null); } /** @@ -110,4 +110,9 @@ public function updateTimestamp(string $sessionId, string $data): bool { return $this->redis->expire($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime'))); } + + public function setTtl(?int $ttl): void + { + $this->ttl = $ttl; + } } From 5996294d3a9b02f40f555cae269051e62ebe8d7e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 30 Nov 2021 16:39:04 +0100 Subject: [PATCH 2/2] Fix whitespace --- .../Session/Storage/Handler/RedisSessionHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index 312af25b10802..7b9785dbce9d6 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -110,9 +110,9 @@ public function updateTimestamp(string $sessionId, string $data): bool { return $this->redis->expire($this->prefix.$sessionId, (int) ($this->ttl ?? ini_get('session.gc_maxlifetime'))); } - + public function setTtl(?int $ttl): void { - $this->ttl = $ttl; + $this->ttl = $ttl; } }