Skip to content

Commit

Permalink
Update zAdd/zRangeByScore documentation (#1815)
Browse files Browse the repository at this point in the history
* Update zAdd functionality
* Fix readability additional params
* Add example of -inf/+inf for zRangeByScore
  • Loading branch information
aalwash committed Jul 21, 2020
1 parent a7662da commit c9ed151
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2763,10 +2763,19 @@ $redis->bzPopMax('zs1', 'zs2', 5);
-----
_**Description**_: Add one or more members to a sorted set or update its score if it already exists


##### *Prototype*
~~~php
$redis->zAdd($key, [ $options ,] $score, $value [, $score1, $value1, ...]);
~~~

##### *Parameters*
*key*
*key*: string
*options*: array (optional)
*score*: double
*value*: string
*score1*: double
*value1*: string

##### *Return value*
*Long* 1 if the element is added. 0 otherwise.
Expand All @@ -2777,6 +2786,9 @@ $redis->zAdd('key', 1, 'val1');
$redis->zAdd('key', 0, 'val0');
$redis->zAdd('key', 5, 'val5');
$redis->zRange('key', 0, -1); // [val0, val1, val5]

// From Redis 3.0.2 it's possible to add options like XX, NX, CH, INCR
$redis->zAdd('key', ['CH'], 5, 'val5', 10, 'val10', 15, 'val15');
~~~

### zCard, zSize
Expand Down Expand Up @@ -2960,6 +2972,7 @@ $redis->zRangeByScore('key', 0, 3); /* ['val0', 'val2'] */
$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2] */
$redis->zRangeByScore('key', 0, 3, ['limit' => [1, 1]]); /* ['val2'] */
$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE, 'limit' => [1, 1]]); /* ['val2' => 2] */
$redis->zRangeByScore('key', '-inf', '+inf', ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */
~~~

### zRangeByLex
Expand Down

0 comments on commit c9ed151

Please sign in to comment.