mirror of
https://github.com/php-win-ext/phpredis.git
synced 2026-03-25 17:42:16 +01:00
@@ -1124,13 +1124,13 @@ var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)
|
||||
|
||||
### ttl, pttl
|
||||
-----
|
||||
_**Description**_: Returns the time to live left for a given key, in seconds. If the key doesn't exist, `FALSE` is returned. pttl returns a time in milliseconds.
|
||||
_**Description**_: Returns the time to live left for a given key in seconds (ttl), or milliseconds (pttl).
|
||||
|
||||
##### *Parameters*
|
||||
*Key*: key
|
||||
|
||||
##### *Return value*
|
||||
Long, the time left to live in seconds.
|
||||
*LONG*: The time to live in seconds. If the key has no ttl, `-1` will be returned, and `-2` if the key doesn't exist.
|
||||
|
||||
##### *Example*
|
||||
~~~
|
||||
|
||||
@@ -1626,18 +1626,26 @@ class Redis_Test extends TestSuite
|
||||
// }
|
||||
|
||||
public function testdbSize() {
|
||||
$this->assertTrue($this->redis->flushDB());
|
||||
$this->redis->set('x', 'y');
|
||||
$this->assertTrue($this->redis->dbSize() === 1);
|
||||
$this->assertTrue($this->redis->flushDB());
|
||||
$this->redis->set('x', 'y');
|
||||
$this->assertTrue($this->redis->dbSize() === 1);
|
||||
}
|
||||
|
||||
public function testttl() {
|
||||
$this->redis->set('x', 'y');
|
||||
$this->redis->setTimeout('x', 5);
|
||||
for($i = 5; $i > 0; $i--) {
|
||||
$this->assertEquals($i, $this->redis->ttl('x'));
|
||||
sleep(1);
|
||||
}
|
||||
$this->redis->set('x', 'y');
|
||||
$this->redis->setTimeout('x', 5);
|
||||
for($i = 5; $i > 0; $i--) {
|
||||
$this->assertEquals($i, $this->redis->ttl('x'));
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
// A key with no TTL
|
||||
$this->redis->del('x'); $this->redis->set('x', 'bar');
|
||||
$this->assertEquals($this->redis->ttl('x'), -1);
|
||||
|
||||
// A key that doesn't exist
|
||||
$this->redis->del('x');
|
||||
$this->assertEquals($this->redis->ttl('x'), -2);
|
||||
}
|
||||
|
||||
public function testPersist() {
|
||||
|
||||
Reference in New Issue
Block a user