Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5c4790

Browse files
Documentation: More command docblocks
1 parent 854f3aa commit a5c4790

3 files changed

Lines changed: 225 additions & 20 deletions

File tree

redis.stub.php

Lines changed: 206 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,40 @@ public function delete(array|string $key, string ...$other_keys): Redis|int|fals
641641

642642
public function discard(): Redis|bool;
643643

644+
//public function restore(string $key, int $timeout, string $value, ?array $options = NULL): bool;
645+
/**
646+
* Dump Redis' internal binary representation of a key.
647+
*
648+
* @see https://redis.io/commands/dump
649+
*
650+
* @param string $key The key to dump.
651+
*
652+
* @return Redis|string A binary string representing the key's value.
653+
*
654+
* <code>
655+
* <?php
656+
* $redis = new Redis(['host' => 'localhost']);
657+
*
658+
* $redis->del('zset');
659+
*
660+
* $redis->zadd('zset', 0, 'zero', 1, 'one', 2, 'two');
661+
*
662+
* // Retrieve the binary representation of the zset
663+
* $binary = $redis->dump('zset');
664+
*
665+
* // Retore it to a different name
666+
* $redis->restore('new-zset', 0, $binary);
667+
*
668+
* // Array
669+
* // (
670+
* // [zero] => 0
671+
* // [one] => 1
672+
* // [two] => 2
673+
* // )
674+
* $redis->zRange('new-zset', 0, -1, true);
675+
* ?>
676+
* </code>
677+
*/
644678
public function dump(string $key): Redis|string;
645679

646680
/**
@@ -1216,21 +1250,46 @@ public function punsubscribe(array $patterns): Redis|array|bool;
12161250
*/
12171251
public function rPop(string $key, int $count = 0): Redis|array|string|bool;
12181252

1219-
/** @return string|Redis */
1220-
public function randomKey();
1253+
/**
1254+
* Return a random key from the current database
1255+
*
1256+
* @see https://redis.io/commands/randomkey
1257+
*
1258+
* @return Redis|string|false A random key name or false if no keys exist
1259+
*
1260+
*/
1261+
public function randomKey(): Redis|string|false;
12211262

12221263
public function rawcommand(string $command, mixed ...$args): mixed;
12231264

1224-
/** @return bool|Redis */
1225-
public function rename(string $key_src, string $key_dst);
1265+
/**
1266+
* Rename a key
1267+
*
1268+
* @param string $old_name The original name of the key
1269+
* @param string $new_name The new name for the key
1270+
*
1271+
* @return Redis|bool True if the key was renamed or false if not.
1272+
*/
1273+
public function rename(string $old_name, string $new_name): Redis|bool;
12261274

12271275
/** @return bool|Redis */
12281276
public function renameNx(string $key_src, string $key_dst);
12291277

1230-
public function reset(): bool;
1278+
/**
1279+
* Reset the state of the connection.
1280+
*
1281+
* @return Redis|bool Should always return true unless there is an error.
1282+
*/
1283+
public function reset(): Redis|bool;
12311284

12321285
public function restore(string $key, int $timeout, string $value, ?array $options = NULL): bool;
12331286

1287+
/**
1288+
* Query whether the connected instance is a primary or replica
1289+
*
1290+
* @return mixed Will return an array with the role of the connected instance unless there is
1291+
* an error.
1292+
*/
12341293
public function role(): mixed;
12351294

12361295
/**
@@ -1415,6 +1474,32 @@ public function sDiffStore(string $dst, string $key, string ...$other_keys): Red
14151474
*/
14161475
public function sInter(array|string $key, string ...$other_keys): Redis|array|false;
14171476

1477+
/**
1478+
* Compute the intersection of one or more sets and return the cardinality of the result.
1479+
*
1480+
* @see https://redis.io/commands/sintercard
1481+
*
1482+
* @param array $keys One or more set key names.
1483+
* @param int $limit A maximum cardinality to return. This is useful to put an upper bound
1484+
* on the amount of work Redis will do.
1485+
*
1486+
* @return Redis|int|false The
1487+
*
1488+
* <code>
1489+
* <?php
1490+
* $redis = new Redis(['host' => 'localhost']);
1491+
*
1492+
* $redis->del('set1', 'set2', 'set3');
1493+
*
1494+
* $redis->sAdd('set1', 'apple', 'pear', 'banana', 'carrot');
1495+
* $redis->sAdd('set2', 'apple', 'banana');
1496+
* $redis->sAdd('set3', 'pear', 'banana');
1497+
*
1498+
* // int(1)
1499+
* var_dump($redis->sInterCard(['set1', 'set2', 'set3']));
1500+
* ?>
1501+
* </code>
1502+
*/
14181503
public function sintercard(array $keys, int $limit = -1): Redis|int|false;
14191504

14201505
/**
@@ -1446,6 +1531,36 @@ public function sintercard(array $keys, int $limit = -1): Redis|int|false;
14461531
*/
14471532
public function sInterStore(array|string $key, string ...$other_keys): Redis|int|false;
14481533

1534+
/**
1535+
* Retrieve every member from a set key.
1536+
*
1537+
* @see https://redis.io/commands/smembers
1538+
*
1539+
* @param string $key The set name.
1540+
*
1541+
* @return Redis|array|false Every element in the set or false on failure.
1542+
*
1543+
* <code>
1544+
* $redis = new Redis(['host' => 'localhost']);
1545+
*
1546+
* $redis->del('tng-crew');
1547+
*
1548+
* $redis->sAdd('tng-crew', ...['Picard', 'Riker', 'Data', 'Worf', 'La Forge', 'Troi', 'Crusher', 'Broccoli']);
1549+
*
1550+
* // Array
1551+
* // (
1552+
* // [0] => Riker
1553+
* // [1] => Crusher
1554+
* // [2] => Troi
1555+
* // [3] => Worf
1556+
* // [4] => LaForge
1557+
* // [5] => Picard
1558+
* // [6] => Broccoli
1559+
* // [7] => Data
1560+
* // )
1561+
* $redis->sMembers('tng-crew');
1562+
* </code>
1563+
*/
14491564
public function sMembers(string $key): Redis|array|false;
14501565

14511566
public function sMisMember(string $key, string $member, string ...$other_members): array;
@@ -1613,6 +1728,38 @@ public function scan(?int &$iterator, ?string $pattern = null, int $count = 0, s
16131728
*/
16141729
public function scard(string $key): Redis|int|false;
16151730

1731+
/**
1732+
* An administrative command used to interact with LUA scripts stored on the server.
1733+
*
1734+
* @see https://redis.io/commands/script
1735+
*
1736+
* @param string $command The script suboperation to execute.
1737+
* @param mixed $args One ore more additional argument
1738+
*
1739+
* @return mixed This command returns various things depending on the specific operation executed.
1740+
*
1741+
* <code>
1742+
* <?php
1743+
* $redis = new Redis(['host' => 'localhost']);
1744+
*
1745+
* $lua = sprintf("return %f", microtime(true));
1746+
*
1747+
* // array(1) {
1748+
* // [0]=>
1749+
* // int(0)
1750+
* // }
1751+
* var_dump($redis->script('exists', sha1($lua)));
1752+
*
1753+
* $redis->script('load', $lua);
1754+
*
1755+
* // array(1) {
1756+
* // [0]=>
1757+
* // int(1)
1758+
* // }
1759+
* var_dump($redis->script('exists', sha1($lua)));
1760+
* ?>
1761+
* </code>
1762+
*/
16161763
public function script(string $command, mixed ...$args): mixed;
16171764

16181765
/**
@@ -2366,15 +2513,35 @@ public function unlink(array|string $key, string ...$other_keys): Redis|int|fals
23662513
*/
23672514
public function unsubscribe(array $channels): Redis|array|bool;
23682515

2369-
/** @return bool|Redis */
2370-
public function unwatch();
2516+
/**
2517+
* Remove any previously WATCH'ed keys in a transaction.
2518+
*
2519+
* @see https://redis.io/commands/unwatch
2520+
* @see https://redis.io/commands/unwatch
2521+
* @see Redis::watch()
2522+
*
2523+
* @return True on success and false on failure.
2524+
*/
2525+
public function unwatch(): Redis|bool;
23712526

23722527
/**
23732528
* @return bool|Redis
23742529
*/
23752530
public function watch(array|string $key, string ...$other_keys);
23762531

2377-
public function wait(int $count, int $timeout): int|false;
2532+
/**
2533+
* Block the client up to the provided timeout until a certain number of replicas have confirmed
2534+
* recieving them.
2535+
*
2536+
* @see https://redis.io/commands/wait
2537+
*
2538+
* @param int $numreplicas The number of replicas we want to confirm write operaions
2539+
* @param int $timeout How long to wait (zero meaning forever).
2540+
*
2541+
* @return Redis|int|false The number of replicas that have confirmed or false on failure.
2542+
*
2543+
*/
2544+
public function wait(int $numreplicas, int $timeout): int|false;
23782545

23792546
public function xack(string $key, string $group, array $ids): int|false;
23802547

@@ -2425,6 +2592,37 @@ public function xdel(string $key, array $ids): Redis|int|false;
24252592
public function xgroup(string $operation, string $key = null, string $group = null, string $id_or_consumer = null,
24262593
bool $mkstream = false, int $entries_read = -2): mixed;
24272594

2595+
/**
2596+
* Retrieve information about a stream key.
2597+
*
2598+
* @param string $operation The specific info operation to perform.
2599+
* @param string $arg1 The first argument (depends on operation)
2600+
* @param string $arg2 The second argument
2601+
* @param int $count The COUNT argument to `XINFO STREAM`
2602+
*
2603+
* @return mixed This command can return different things depending on the operation being called.
2604+
*
2605+
* <code>
2606+
* <?php
2607+
* $redis = new Redis(['host' => 'localhost']);
2608+
*
2609+
* $redis->del('stream');
2610+
*
2611+
* $redis->xAdd('stream', "0-1", ['payload' => '0-1']);
2612+
* $redis->xAdd('stream', "0-2", ['payload' => '0-2']);
2613+
* $redis->xAdd('stream', "0-3", ['payload' => '0-3']);
2614+
*
2615+
* // Retrieve any consmers for a given key
2616+
* $redis->xInfo('CONSUMERS', 'stream');
2617+
*
2618+
* // Retrieve any groups for a given key
2619+
* $redis->xInfo('GROUPS', 'stream');
2620+
*
2621+
* // Retrieve general stream information along with messages
2622+
* $redis->xInfo('STREAM', 'stream');
2623+
* ?>
2624+
* </code>
2625+
*/
24282626
public function xinfo(string $operation, ?string $arg1 = null, ?string $arg2 = null, int $count = -1): mixed;
24292627

24302628

redis_arginfo.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 52904ef54aa9857103e3bb65c089cf09833c507c */
2+
* Stub hash: ceb169a872a3df211ded811c1a5ac102832a9158 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "null")
@@ -650,21 +650,25 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_rPop, 0, 1, Redi
650650
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "0")
651651
ZEND_END_ARG_INFO()
652652

653-
#define arginfo_class_Redis_randomKey arginfo_class_Redis___destruct
653+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_randomKey, 0, 0, Redis, MAY_BE_STRING|MAY_BE_FALSE)
654+
ZEND_END_ARG_INFO()
654655

655656
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_rawcommand, 0, 1, IS_MIXED, 0)
656657
ZEND_ARG_TYPE_INFO(0, command, IS_STRING, 0)
657658
ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
658659
ZEND_END_ARG_INFO()
659660

660-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_rename, 0, 0, 2)
661+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_rename, 0, 2, Redis, MAY_BE_BOOL)
662+
ZEND_ARG_TYPE_INFO(0, old_name, IS_STRING, 0)
663+
ZEND_ARG_TYPE_INFO(0, new_name, IS_STRING, 0)
664+
ZEND_END_ARG_INFO()
665+
666+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_renameNx, 0, 0, 2)
661667
ZEND_ARG_TYPE_INFO(0, key_src, IS_STRING, 0)
662668
ZEND_ARG_TYPE_INFO(0, key_dst, IS_STRING, 0)
663669
ZEND_END_ARG_INFO()
664670

665-
#define arginfo_class_Redis_renameNx arginfo_class_Redis_rename
666-
667-
#define arginfo_class_Redis_reset arginfo_class_Redis_clearLastError
671+
#define arginfo_class_Redis_reset arginfo_class_Redis_bgSave
668672

669673
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_restore, 0, 3, _IS_BOOL, 0)
670674
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
@@ -861,15 +865,15 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_unsubscribe, 0,
861865
ZEND_ARG_TYPE_INFO(0, channels, IS_ARRAY, 0)
862866
ZEND_END_ARG_INFO()
863867

864-
#define arginfo_class_Redis_unwatch arginfo_class_Redis___destruct
868+
#define arginfo_class_Redis_unwatch arginfo_class_Redis_bgSave
865869

866870
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_watch, 0, 0, 1)
867871
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
868872
ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0)
869873
ZEND_END_ARG_INFO()
870874

871875
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Redis_wait, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
872-
ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0)
876+
ZEND_ARG_TYPE_INFO(0, numreplicas, IS_LONG, 0)
873877
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
874878
ZEND_END_ARG_INFO()
875879

redis_legacy_arginfo.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 52904ef54aa9857103e3bb65c089cf09833c507c */
2+
* Stub hash: ceb169a872a3df211ded811c1a5ac102832a9158 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, options)
@@ -558,12 +558,15 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_rawcommand, 0, 0, 1)
558558
ZEND_END_ARG_INFO()
559559

560560
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_rename, 0, 0, 2)
561+
ZEND_ARG_INFO(0, old_name)
562+
ZEND_ARG_INFO(0, new_name)
563+
ZEND_END_ARG_INFO()
564+
565+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_renameNx, 0, 0, 2)
561566
ZEND_ARG_INFO(0, key_src)
562567
ZEND_ARG_INFO(0, key_dst)
563568
ZEND_END_ARG_INFO()
564569

565-
#define arginfo_class_Redis_renameNx arginfo_class_Redis_rename
566-
567570
#define arginfo_class_Redis_reset arginfo_class_Redis___destruct
568571

569572
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_restore, 0, 0, 3)
@@ -733,7 +736,7 @@ ZEND_END_ARG_INFO()
733736
#define arginfo_class_Redis_watch arginfo_class_Redis_del
734737

735738
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_wait, 0, 0, 2)
736-
ZEND_ARG_INFO(0, count)
739+
ZEND_ARG_INFO(0, numreplicas)
737740
ZEND_ARG_INFO(0, timeout)
738741
ZEND_END_ARG_INFO()
739742

0 commit comments

Comments
 (0)