Skip to content

Commit cd97786

Browse files
committed
Add new commands pTtl(), pExpire(), pExpireAt()
1 parent 7f706de commit cd97786

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

redisphp.php

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Helper autocomplete for php redis extension
44
* @author Max Kamashev <[email protected]>
55
* @link https://github.com/ukko/phpredis-phpdoc
6+
*
7+
* @method echo string $string Sends a string to Redis, which replies with the same string
68
*/
79
class Redis
810
{
@@ -131,7 +133,7 @@ public function setOption( $name, $value ) {}
131133
* Get client option
132134
*
133135
* @param string $name parameter name
134-
* @return Parameter value.
136+
* @return int Parameter value.
135137
* @example
136138
* // return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, or Redis::SERIALIZER_IGBINARY.
137139
* $redis->getOption(Redis::OPT_SERIALIZER);
@@ -146,7 +148,6 @@ public function getOption( $name ) {}
146148
*/
147149
public function ping( ) {}
148150

149-
150151
/**
151152
* Get the value related to the specified key
152153
*
@@ -817,7 +818,7 @@ public function lRemove( $key, $value, $count ) {}
817818
* @param int $position Redis::BEFORE | Redis::AFTER
818819
* @param string $pivot
819820
* @param string $value
820-
* @return The number of the elements in the list, -1 if the pivot didn't exists.
821+
* @return int The number of the elements in the list, -1 if the pivot didn't exists.
821822
* @link http://redis.io/commands/linsert
822823
* @example
823824
* <pre>
@@ -1371,6 +1372,23 @@ public function renameNx( $srcKey, $dstKey ) {}
13711372
*/
13721373
public function expire( $key, $ttl ) {}
13731374

1375+
/**
1376+
* Sets an expiration date (a timeout in milliseconds) on an item.
1377+
*
1378+
* @param string $key The key that will disappear.
1379+
* @param int $pttl The key's remaining Time To Live, in milliseconds.
1380+
* @return bool: TRUE in case of success, FALSE in case of failure.
1381+
* @link http://redis.io/commands/pexpire
1382+
* @example
1383+
* <pre>
1384+
* $redis->set('x', '42');
1385+
* $redis->pExpire('x', 11500); // x will disappear in 11500 milliseconds.
1386+
* $redis->ttl('x'); // 12
1387+
* $redis->pttl('x'); // 11500
1388+
* </pre>
1389+
*/
1390+
public function pExpire( $key, $ttl ) {}
1391+
13741392
/**
13751393
* @see expire()
13761394
* @param string $key
@@ -1397,6 +1415,23 @@ public function setTimeout( $key, $ttl ) {}
13971415
*/
13981416
public function expireAt( $key, $timestamp ) {}
13991417

1418+
/**
1419+
* Sets an expiration date (a timestamp) on an item. Requires a timestamp in milliseconds
1420+
*
1421+
* @param string $key The key that will disappear.
1422+
* @param int $timestamp Unix timestamp. The key's date of death, in seconds from Epoch time.
1423+
* @return bool: TRUE in case of success, FALSE in case of failure.
1424+
* @link http://redis.io/commands/pexpireat
1425+
* @example
1426+
* <pre>
1427+
* $redis->set('x', '42');
1428+
* $redis->pExpireAt('x', 1555555555005);
1429+
* echo $redis->ttl('x'); // 218270121
1430+
* echo $redis->pttl('x'); // 218270120575
1431+
* </pre>
1432+
*/
1433+
public function pExpireAt( $key, $timestamp ) {}
1434+
14001435
/**
14011436
* Returns the keys that match a certain pattern.
14021437
*
@@ -1523,7 +1558,9 @@ public function lastSave( ) {}
15231558
* Returns the type of data pointed by a given key.
15241559
*
15251560
* @param string $key
1526-
* @return Depending on the type of the data pointed by the key,
1561+
* @return int
1562+
*
1563+
* Depending on the type of the data pointed by the key,
15271564
* this method will return the following value:
15281565
* - string: Redis::REDIS_STRING
15291566
* - set: Redis::REDIS_SET
@@ -1771,6 +1808,18 @@ public function resetStat( ) {}
17711808
*/
17721809
public function ttl( $key ) {}
17731810

1811+
/**
1812+
* Returns a time to live left for a given key, in milliseconds.
1813+
*
1814+
* If the key doesn't exist, FALSE is returned.
1815+
*
1816+
* @param string $key
1817+
* @return int the time left to live in milliseconds.
1818+
* @link http://redis.io/commands/pttl
1819+
* @example $redis->pttl('key');
1820+
*/
1821+
public function pttl( $key ) {}
1822+
17741823
/**
17751824
* Remove the expiration timer from a key.
17761825
*

0 commit comments

Comments
 (0)