Skip to content

Commit c9ed151

Browse files
authored
Update zAdd/zRangeByScore documentation (phpredis#1815)
* Update zAdd functionality * Fix readability additional params * Add example of -inf/+inf for zRangeByScore
1 parent a7662da commit c9ed151

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.markdown

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2763,10 +2763,19 @@ $redis->bzPopMax('zs1', 'zs2', 5);
27632763
-----
27642764
_**Description**_: Add one or more members to a sorted set or update its score if it already exists
27652765

2766+
2767+
##### *Prototype*
2768+
~~~php
2769+
$redis->zAdd($key, [ $options ,] $score, $value [, $score1, $value1, ...]);
2770+
~~~
2771+
27662772
##### *Parameters*
2767-
*key*
2773+
*key*: string
2774+
*options*: array (optional)
27682775
*score*: double
27692776
*value*: string
2777+
*score1*: double
2778+
*value1*: string
27702779

27712780
##### *Return value*
27722781
*Long* 1 if the element is added. 0 otherwise.
@@ -2777,6 +2786,9 @@ $redis->zAdd('key', 1, 'val1');
27772786
$redis->zAdd('key', 0, 'val0');
27782787
$redis->zAdd('key', 5, 'val5');
27792788
$redis->zRange('key', 0, -1); // [val0, val1, val5]
2789+
2790+
// From Redis 3.0.2 it's possible to add options like XX, NX, CH, INCR
2791+
$redis->zAdd('key', ['CH'], 5, 'val5', 10, 'val10', 15, 'val15');
27802792
~~~
27812793

27822794
### zCard, zSize
@@ -2960,6 +2972,7 @@ $redis->zRangeByScore('key', 0, 3); /* ['val0', 'val2'] */
29602972
$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2] */
29612973
$redis->zRangeByScore('key', 0, 3, ['limit' => [1, 1]]); /* ['val2'] */
29622974
$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE, 'limit' => [1, 1]]); /* ['val2' => 2] */
2975+
$redis->zRangeByScore('key', '-inf', '+inf', ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */
29632976
~~~
29642977

29652978
### zRangeByLex

0 commit comments

Comments
 (0)