From 5a9c01716f066a7ff851d4ba285b479d0d1be110 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 30 Jun 2024 12:45:14 +0700 Subject: [PATCH] [ticket/17358] Properly handle Redis cache expiration time PHPBB-17358 --- phpBB/phpbb/cache/driver/redis.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/cache/driver/redis.php b/phpBB/phpbb/cache/driver/redis.php index eaeb529918..f5c70c3a52 100644 --- a/phpBB/phpbb/cache/driver/redis.php +++ b/phpBB/phpbb/cache/driver/redis.php @@ -129,6 +129,10 @@ class redis extends \phpbb\cache\driver\memory /** * Store data in the cache * + * For the info, see https://phpredis.github.io/phpredis/Redis.html#method_set, + * https://redis.io/docs/latest/commands/set/ + * and https://redis.io/docs/latest/commands/expire/#appendix-redis-expires + * * @access protected * @param string $var Cache key * @param mixed $data Data to store @@ -137,11 +141,7 @@ class redis extends \phpbb\cache\driver\memory */ function _write($var, $data, $ttl = 2592000) { - if ($ttl == 0) - { - return $this->redis->set($var, $data); - } - return $this->redis->setex($var, $ttl, $data); + return $this->redis->set($var, $data, ['EXAT' => time() + $ttl]); } /**