From 34b8e42bf01cd949f2d47d66e9dab90451527a00 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 21 Dec 2020 13:07:20 +0100 Subject: [PATCH] Actually set the TTL on redis set Else well the keys remain for ever and ever. Signed-off-by: Roeland Jago Douma --- lib/private/Memcache/Redis.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php index dfbdd02956..56470afa0c 100644 --- a/lib/private/Memcache/Redis.php +++ b/lib/private/Memcache/Redis.php @@ -101,7 +101,13 @@ class Redis extends Cache implements IMemcacheTTL { if (!is_int($value)) { $value = json_encode($value); } - return self::$cache->setnx($this->getPrefix() . $key, $value); + + $args = ['nx']; + if ($ttl !== 0 && is_int($ttl)) { + $args['ex'] = $ttl; + } + + return self::$cache->set($this->getPrefix() . $key, $value, $args); } /**