Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

ZINCRBY

Last updated
ZINCRBY key increment member
Group
Sorted set
Complexity
O(log(N)) where N is the size of the sorted set
Arity
4 (exactly, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

ZINCRBY adds increment to the score of member in the sorted set at key and returns the new score. A missing member is added with increment as its score, and a missing key is created. Use a negative increment to subtract.

Case RESP2 RESP3
Success Bulk string: the new score Double: the new score

Errors:

  • WRONGTYPE if key holds a value that is not a sorted set.
  • ERR value is not a valid float if increment is not a number.
  • ERR resulting score is not a number (NaN) if the sum would be NaN (for example adding -inf to a score of inf). Nothing changes in that case.
127.0.0.1:6379> ZADD board 100 "alice"
(integer) 1
127.0.0.1:6379> ZINCRBY board 15 "alice"
"115"
127.0.0.1:6379> ZINCRBY board -2.5 "bob"
"-2.5"

Same replies as Redis 7.4 and Valkey 8. HotKV checks the key’s type before the increment, so a bad increment on a key of another type replies WRONGTYPE rather than the float error.

ZADD, ZSCORE, HINCRBYFLOAT