Skip to content

Commit 99ec24b

Browse files
alexander-schranzmichael-grunder
authored andcommitted
Add documentation for zpopmin and zpopmax
1 parent 8ee4abb commit 99ec24b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.markdown

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,7 @@ while(($arr_mems = $redis->sScan('set', $it, "*pattern*"))!==FALSE) {
26532653
* [zCount](#zcount) - Count the members in a sorted set with scores within the given values
26542654
* [zIncrBy](#zincrby) - Increment the score of a member in a sorted set
26552655
* [zinterstore, zInter](#zinterstore-zinter) - Intersect multiple sorted sets and store the resulting sorted set in a new key
2656+
* [zPop](#zpop) - Redis can pop the highest or lowest scoring member from one a ZSET.
26562657
* [zRange](#zrange) - Return a range of members in a sorted set, by index
26572658
* [zRangeByScore, zRevRangeByScore](#zrangebyscore-zrevrangebyscore) - Return a range of members in a sorted set, by score
26582659
* [zRangeByLex](#zrangebylex) - Return a lexicographical range from members that share the same score
@@ -2816,6 +2817,33 @@ $redis->zinterstore('ko4', ['k1', 'k2'], [1, 5], 'max'); /* 2, 'ko4' => ['val3',
28162817

28172818
**Note:** `zInter` is an alias for `zinterstore` and will be removed in future versions of phpredis.
28182819

2820+
### zPop
2821+
-----
2822+
_**Description**_: Can pop the highest or lowest scoring members from one ZSETs. There are two commands (`ZPOPMIN` and `ZPOPMAX` for popping the lowest and highest scoring elements respectively.)
2823+
2824+
##### *Prototype*
2825+
~~~php
2826+
$redis->zPopMin(string $key, int $count): array
2827+
$redis->zPopMax(string $key, int $count): array
2828+
2829+
$redis->zPopMin(string $key, int $count): array
2830+
$redis->zPopMax(string $key, int $count): array
2831+
~~~
2832+
2833+
##### *Return value*
2834+
*ARRAY:* Either an array with the key member and score of the higest or lowest element or an empty array if there is no element available.
2835+
2836+
##### *Example*
2837+
~~~php
2838+
/* Wait up to 5 seconds to pop the *lowest* scoring member from sets `zs1` and `zs2`. */
2839+
$redis->bzPopMin(['zs1', 'zs2'], 5);
2840+
$redis->bzPopMin('zs1', 'zs2', 5);
2841+
2842+
/* Wait up to 5 seconds to pop the *highest* scoring member from sets `zs1` and `zs2` */
2843+
$redis->bzPopMax(['zs1', 'zs2'], 5);
2844+
$redis->bzPopMax('zs1', 'zs2', 5);
2845+
~~~
2846+
28192847
### zRange
28202848
-----
28212849
_**Description**_: Returns a range of elements from the ordered set stored at the specified key, with values in the range [start, end].

0 commit comments

Comments
 (0)