diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-10-27 03:05:54 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-10-27 04:55:55 +0300 |
commit | 43da8dd9d8e436264630e1623defebc139bad599 (patch) | |
tree | 1b1a553508ddc63adae1436cb1581a24317e25c9 /tests | |
parent | 375d093d9482dfd794b5f6fb230b689f0540bbc9 (diff) |
Refactor BRPOPLPUSH and add B[LR]POP documentation
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RedisTest.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php index cd9f631b..466a83a6 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -2498,6 +2498,7 @@ class Redis_Test extends TestSuite $this->redis->lpush('{list}y', '456'); // y = [456, 123] $this->assertEquals($this->redis->brpoplpush('{list}x', '{list}y', 1), 'abc'); // we RPOP x, yielding abc. + $this->assertEquals($this->redis->lrange('{list}x', 0, -1), ['def']); // only def remains in x. $this->assertEquals($this->redis->lrange('{list}y', 0, -1), ['abc', '456', '123']); // abc has been lpushed to y. @@ -2506,6 +2507,15 @@ class Redis_Test extends TestSuite $this->assertTrue(FALSE === $this->redis->brpoplpush('{list}x', '{list}y', 1)); $this->assertTrue([] === $this->redis->lrange('{list}x', 0, -1)); $this->assertTrue([] === $this->redis->lrange('{list}y', 0, -1)); + + if (!$this->minVersionCheck('6.0.0')) + return; + + // Redis >= 6.0.0 allows floating point timeouts + $st = microtime(true); + $this->assertEquals(FALSE, $this->redis->brpoplpush('{list}x', '{list}y', .1)); + $et = microtime(true); + $this->assertTrue($et - $st < 1.0); } public function testZAddFirstArg() { |