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

Skip to content

Commit f05ba81

Browse files
Documentation: Add several more docblocs
- Add a bunch more docblocks with examples - Link every relevant RedisCluster method to the Redis docs.
1 parent cf63e96 commit f05ba81

6 files changed

Lines changed: 635 additions & 10 deletions

redis.stub.php

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,12 +1563,173 @@ public function sInterStore(array|string $key, string ...$other_keys): Redis|int
15631563
*/
15641564
public function sMembers(string $key): Redis|array|false;
15651565

1566-
public function sMisMember(string $key, string $member, string ...$other_members): array;
1566+
/**
1567+
* Check if one or more values are members of a set.
1568+
*
1569+
* @see https://redis.io/commands/smismember
1570+
* @see https://redis.io/commands/smember
1571+
* @see Redis::smember()
1572+
*
1573+
* @param string $key The set to query.
1574+
* @param string $member The first value to test if exists in the set.
1575+
* @param string $other_members Any number of additional values to check.
1576+
*
1577+
* @return Redis|array|false An array of integers representing whether each passed value
1578+
* was a member of the set.
1579+
*
1580+
* <code>
1581+
* <?php
1582+
* $redis = new Redis(['host' => 'localhost']);
1583+
*
1584+
* $redis->del('ds9-crew');
1585+
* $redis->sAdd('ds9-crew', ...["Sisko", "Kira", "Dax", "Worf", "Bashir", "O'Brien"]);
1586+
*
1587+
* $names = ['Sisko', 'Picard', 'Data', 'Worf'];
1588+
* $members = $redis->sMIsMember('ds9-crew', ...$names);
1589+
*
1590+
* // array(4) {
1591+
* // ["Sisko"]=>
1592+
* // int(1)
1593+
* // ["Picard"]=>
1594+
* // int(0)
1595+
* // ["Data"]=>
1596+
* // int(0)
1597+
* // ["Worf"]=>
1598+
* // int(1)
1599+
* // }
1600+
* var_dump(array_combine($names, $members));
1601+
* ?>
1602+
* </code>
1603+
*/
1604+
public function sMisMember(string $key, string $member, string ...$other_members): Redis|array|false;
15671605

1606+
/**
1607+
* Pop a member from one set and push it onto another. This command will create the
1608+
* destination set if it does not currently exist.
1609+
*
1610+
* @see https://redis.io/commands/smove
1611+
*
1612+
* @param string $src The source set.
1613+
* @param string $dst The destination set.
1614+
* @param mixed $value The member you wish to move.
1615+
*
1616+
* @return Redis|bool True if the member was moved, and false if it wasn't in the set.
1617+
*
1618+
* <code>
1619+
* <?php
1620+
* $redis = new Redis(['host' => 'localhost']);
1621+
*
1622+
* $redis->del('numbers', 'evens');
1623+
* $redis->sAdd('numbers', 'zero', 'one', 'two', 'three', 'four');
1624+
*
1625+
* $redis->sMove('numbers', 'evens', 'zero');
1626+
* $redis->sMove('numbers', 'evens', 'two');
1627+
* $redis->sMove('numbers', 'evens', 'four');
1628+
*
1629+
* // array(2) {
1630+
* // [0]=>
1631+
* // string(5) "three"
1632+
* // [1]=>
1633+
* // string(3) "one"
1634+
* // }
1635+
* var_dump($redis->sMembers('numbers'));
1636+
*
1637+
* // array(3) {
1638+
* // [0]=>
1639+
* // string(4) "zero"
1640+
* // [1]=>
1641+
* // string(3) "two"
1642+
* // [2]=>
1643+
* // string(4) "four"
1644+
* // }
1645+
* var_dump($redis->sMembers('evens'));
1646+
*
1647+
* ?>
1648+
* </code>
1649+
*/
15681650
public function sMove(string $src, string $dst, mixed $value): Redis|bool;
15691651

1652+
/**
1653+
* Remove one or more elements from a set.
1654+
*
1655+
* @see https://redis.io/commands/spop
1656+
*
1657+
* @param string $key The set in question.
1658+
* @param int $count An optional number of members to pop. This defaults to
1659+
* removing one element.
1660+
*
1661+
* <code>
1662+
* <?php
1663+
* $redis = new Redis(['host' => 'localhost']);
1664+
*
1665+
* <?php
1666+
*
1667+
* $redis = new Redis(['host' => 'localhost']);
1668+
*
1669+
* $redis->del('numbers', 'evens');
1670+
* $redis->sAdd('numbers', 'zero', 'one', 'two', 'three', 'four');
1671+
*
1672+
* $redis->sMove('numbers', 'evens', 'zero');
1673+
* $redis->sMove('numbers', 'evens', 'two');
1674+
* $redis->sMove('numbers', 'evens', 'four');
1675+
*
1676+
* // array(2) {
1677+
* // [0]=>
1678+
* // string(5) "three"
1679+
* // [1]=>
1680+
* // string(3) "one"
1681+
* // }
1682+
* var_dump($redis->sMembers('numbers'));
1683+
*
1684+
* // array(3) {
1685+
* // [0]=>
1686+
* // string(4) "zero"
1687+
* // [1]=>
1688+
* // string(3) "two"
1689+
* // [2]=>
1690+
* // string(4) "four"
1691+
* // }
1692+
* var_dump($redis->sMembers('evens'));
1693+
* ?>
1694+
* </code>
1695+
*/
15701696
public function sPop(string $key, int $count = 0): Redis|string|array|false;
15711697

1698+
/**
1699+
* Retrieve one or more random members of a set.
1700+
*
1701+
* @param string $key The set to query.
1702+
* @param int $count An optional count of members to return.
1703+
*
1704+
* If this value is positive, Redis will return *up to* the requested
1705+
* number but with unique elements that will never repeat. This means
1706+
* you may recieve fewer then `$count` replies.
1707+
*
1708+
* If the number is negative, Redis will return the exact number requested
1709+
* but the result may contain duplicate elements.
1710+
*
1711+
* @return Redis|array|string|false One or more random members or false on failure.
1712+
*
1713+
* <code>
1714+
* <?php
1715+
* $redis = new Redis(['host' => 'localhost']);
1716+
*
1717+
* $redis->del('elder-gods');
1718+
*
1719+
* $redis->sAdd('elder-gods', ["Cthulhu", "Azathoth", "Daoloth", "D'endrrah"]);
1720+
*
1721+
* // A single random member returned.
1722+
* $rng1 = $redis->sRandMember('elder-gods');
1723+
*
1724+
* // Up to SCARD `elder-gods` random members returned
1725+
* $rng2 = $redis->sRandMember('elder-gods', 9999);
1726+
*
1727+
* // 9999 elements from the set returned with duplicates
1728+
* $rng3 = $redis->sRandMember('elder-gods', -9999);
1729+
* ?>
1730+
* </code>
1731+
*
1732+
*/
15721733
public function sRandMember(string $key, int $count = 0): Redis|string|array|false;
15731734

15741735
/**

redis_arginfo.h

Lines changed: 2 additions & 6 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: 42952974e3686f29934dfff1ebba07150942a405 */
2+
* Stub hash: 4c4d58bf2ce686c82287a69fef109267828a2d9b */
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")
@@ -720,11 +720,7 @@ ZEND_END_ARG_INFO()
720720

721721
#define arginfo_class_Redis_sMembers arginfo_class_Redis_hGetAll
722722

723-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_sMisMember, 0, 2, IS_ARRAY, 0)
724-
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
725-
ZEND_ARG_TYPE_INFO(0, member, IS_STRING, 0)
726-
ZEND_ARG_VARIADIC_TYPE_INFO(0, other_members, IS_STRING, 0)
727-
ZEND_END_ARG_INFO()
723+
#define arginfo_class_Redis_sMisMember arginfo_class_Redis_geohash
728724

729725
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_sMove, 0, 3, Redis, MAY_BE_BOOL)
730726
ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0)

0 commit comments

Comments
 (0)