From 4f0fae8f0097d6859668585edf30018dc852ce24 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
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 <roeland@famdouma.nl>
---
 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 dfbdd029565..56470afa0c5 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);
 	}
 
 	/**
-- 
GitLab