aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-12-05 16:01:46 +0100
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-12-21 15:14:27 +0100
commitff62154a79498b16e5c4b617e073aea03afc2a84 (patch)
tree9fc13370639c587f6e586ce95adf54d556ab754d /tests
parent7394645eb7f2f1d2831bb7c106737087992e4da4 (diff)
downloadnextcloud-server-ff62154a79498b16e5c4b617e073aea03afc2a84.tar.gz
nextcloud-server-ff62154a79498b16e5c4b617e073aea03afc2a84.zip
adjust redis compareSetTTL to use a lua script
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Memcache/RedisTest.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/Memcache/RedisTest.php b/tests/lib/Memcache/RedisTest.php
index b94b69a5e6a..27c6fc11ee8 100644
--- a/tests/lib/Memcache/RedisTest.php
+++ b/tests/lib/Memcache/RedisTest.php
@@ -9,11 +9,18 @@
namespace Test\Memcache;
+use OC\Memcache\Redis;
+
/**
* @group Memcache
* @group Redis
*/
class RedisTest extends Cache {
+ /**
+ * @var Redis cache;
+ */
+ protected $instance;
+
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
@@ -62,4 +69,18 @@ class RedisTest extends Cache {
$this->assertEquals(sha1($script[0]), $script[1]);
}
}
+
+ public function testCasTtlNotChanged() {
+ $this->instance->set('foo', 'bar', 50);
+ $this->assertTrue($this->instance->compareSetTTL('foo', 'bar', 100));
+ // allow for 1s of inaccuracy due to time moving forward
+ $this->assertLessThan(1, 100 - $this->instance->getTTL('foo'));
+ }
+
+ public function testCasTtlChanged() {
+ $this->instance->set('foo', 'bar1', 50);
+ $this->assertFalse($this->instance->compareSetTTL('foo', 'bar', 100));
+ // allow for 1s of inaccuracy due to time moving forward
+ $this->assertLessThan(1, 50 - $this->instance->getTTL('foo'));
+ }
}