Browse Source

Merge pull request #24796 from nextcloud/fix/set_ttl_on_set_redis

Actually set the TTL on redis set
Roeland Jago Douma 3 years ago
parent
commit
5579b1d252
1 changed files with 7 additions and 1 deletions
  1. 7 1
      lib/private/Memcache/Redis.php

+ 7 - 1
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);
 	}
 
 	/**