summaryrefslogtreecommitdiffstats
path: root/iredis/data/commands/zadd.md
diff options
context:
space:
mode:
Diffstat (limited to 'iredis/data/commands/zadd.md')
-rw-r--r--iredis/data/commands/zadd.md20
1 files changed, 15 insertions, 5 deletions
diff --git a/iredis/data/commands/zadd.md b/iredis/data/commands/zadd.md
index 589eaf3..f14b085 100644
--- a/iredis/data/commands/zadd.md
+++ b/iredis/data/commands/zadd.md
@@ -10,13 +10,17 @@ not hold a sorted set, an error is returned.
The score values should be the string representation of a double precision
floating point number. `+inf` and `-inf` values are valid values as well.
-## ZADD options (Redis 3.0.2 or greater)
+## ZADD options
ZADD supports a list of options, specified after the name of the key and before
the first score argument. Options are:
-- **XX**: Only update elements that already exist. Never add elements.
-- **NX**: Don't update already existing elements. Always add new elements.
+- **XX**: Only update elements that already exist. Don't add new elements.
+- **NX**: Only add new elements. Don't update already existing elements.
+- **LT**: Only update existing elements if the new score is **less than** the
+ current score. This flag doesn't prevent adding new elements.
+- **GT**: Only update existing elements if the new score is **greater than** the
+ current score. This flag doesn't prevent adding new elements.
- **CH**: Modify the return value from the number of new elements added, to the
total number of elements changed (CH is an abbreviation of _changed_). Changed
elements are **new elements added** and elements already existing for which
@@ -26,6 +30,8 @@ the first score argument. Options are:
- **INCR**: When this option is specified `ZADD` acts like `ZINCRBY`. Only one
score-element pair can be specified in this mode.
+Note: The **GT**, **LT** and **NX** options are mutually exclusive.
+
## Range of integer scores that can be expressed precisely
Redis sorted sets use a _double 64-bit floating point number_ to represent the
@@ -74,8 +80,10 @@ is also possible to query sorted sets by range of scores using `ZRANGEBYSCORE`).
@integer-reply, specifically:
-- The number of elements added to the sorted set, not including elements already
- existing for which the score was updated.
+- When used without optional arguments, the number of elements added to the
+ sorted set (excluding score updates).
+- If the `CH` option is specified, the number of elements that were changed
+ (added or updated).
If the `INCR` option is specified, the return value will be @bulk-string-reply:
@@ -87,6 +95,8 @@ If the `INCR` option is specified, the return value will be @bulk-string-reply:
- `>= 2.4`: Accepts multiple elements. In Redis versions older than 2.4 it was
possible to add or update a single member per call.
+- `>= 3.0.2`: Added the `XX`, `NX`, `CH` and `INCR` options.
+- `>= 6.2`: Added the `GT` and `LT` options.
@examples