This commit is contained in:
Andrew Nicols 2024-06-04 11:06:34 +08:00
commit 1790452026
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 11 additions and 2 deletions

View File

@ -469,7 +469,7 @@ class cachestore_redis extends cache_store implements cache_is_key_aware, cache_
$ttlparams[] = $key;
}
}
if ($usettl) {
if ($usettl && count($ttlparams) > 0) {
// Store all the key values with current time.
$this->redis->zAdd($this->hash . self::TTL_SUFFIX, [], ...$ttlparams);
// The return value to the zAdd function never indicates whether the operation succeeded

View File

@ -29,7 +29,7 @@ namespace cachestore_redis;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \cachestore_redis
*/
class ttl_test extends \advanced_testcase {
final class ttl_test extends \advanced_testcase {
/** @var \cachestore_redis|null Cache store */
protected $store = null;
@ -66,6 +66,15 @@ class ttl_test extends \advanced_testcase {
}
}
/**
* Test calling set_many with an empty array
*
* Trivial test to ensure we don't trigger an ArgumentCountError when calling zAdd with invalid parameters
*/
public function test_set_many_empty(): void {
$this->assertEquals(0, $this->store->set_many([]));
}
/**
* Tests expiring data.
*/