[ticket/17358] Properly handle Redis cache expiration time

PHPBB-17358
This commit is contained in:
rxu 2024-06-30 12:45:14 +07:00
parent 3647cf2cfe
commit 5a9c01716f
No known key found for this signature in database
GPG key ID: 955F0567380E586A

View file

@ -129,6 +129,10 @@ class redis extends \phpbb\cache\driver\memory
/** /**
* Store data in the cache * 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 * @access protected
* @param string $var Cache key * @param string $var Cache key
* @param mixed $data Data to store * @param mixed $data Data to store
@ -137,11 +141,7 @@ class redis extends \phpbb\cache\driver\memory
*/ */
function _write($var, $data, $ttl = 2592000) function _write($var, $data, $ttl = 2592000)
{ {
if ($ttl == 0) return $this->redis->set($var, $data, ['EXAT' => time() + $ttl]);
{
return $this->redis->set($var, $data);
}
return $this->redis->setex($var, $ttl, $data);
} }
/** /**