diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-10-26 06:22:02 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-10-26 11:38:42 +0300 |
commit | dc1f2398d014d43c402626931ed3b78c4dd1f96e (patch) | |
tree | d2a17e722c52627dda20294989c66351919ddbf4 /tests | |
parent | 69355faae0ff77bd69fbadba4b43779eac1b703e (diff) |
TOUCH command
Implement the TOUCH command and refactor several of our "variadic key"
commands, which were previously all using their own specific handlers.
While refactoring the code, I changed `EXISTS` to require one key (it
had previously been set to require zero keys).
Additonally, it looks like we had a disparity in two commands which
should be idential to PhpRedis: SINTERSTORE and SUNIONSTORE.
Previously, SINTERSTORE required only one argument but SUNIONSTORE 2.
I simply changed SUNIONSTORE to also only require a single argument,
since that argument could be an array.
```php
$redis->sInterStore(['dst', 'src1', 'src2']);
$redis->sUnionStore(['dst', 'src1', 'src2']);
```
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RedisTest.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/RedisTest.php b/tests/RedisTest.php index 028116b4..cd9f631b 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -894,8 +894,7 @@ class Redis_Test extends TestSuite } - public function testExists() - { + public function testExists() { /* Single key */ $this->redis->del('key'); $this->assertEquals(0, $this->redis->exists('key')); @@ -917,6 +916,22 @@ class Redis_Test extends TestSuite $this->assertEquals(count($mkeys), call_user_func_array([$this->redis, 'exists'], $mkeys)); } + public function testTouch() { + if (!$this->minVersionCheck('3.2.1')) + $this->markTestSkipped(); + + $this->redis->del('notakey'); + + $this->assertTrue($this->redis->mset(['{idle}1' => 'beep', '{idle}2' => 'boop'])); + usleep(1100000); + $this->assertTrue($this->redis->object('idletime', '{idle}1') >= 1); + $this->assertTrue($this->redis->object('idletime', '{idle}2') >= 1); + + $this->assertEquals(2, $this->redis->touch('{idle}1', '{idle}2', '{idle}notakey')); + $this->assertTrue($this->redis->object('idletime', '{idle}1') == 0); + $this->assertTrue($this->redis->object('idletime', '{idle}2') == 0); + } + public function testKeys() { $pattern = 'keys-test-'; |