Skip to content

Commit

Permalink
Merge pull request #24798 from nextcloud/backport/24796/stable20
Browse files Browse the repository at this point in the history
[stable20] Actually set the TTL on redis set
  • Loading branch information
rullzer authored Dec 22, 2020
2 parents 1b19cc5 + 34b8e42 commit d5f4ca6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/private/Memcache/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ public function add($key, $value, $ttl = 0) {
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);
}

/**
Expand Down

0 comments on commit d5f4ca6

Please sign in to comment.