Redis Zincrby Command
The Redis Zincrby command increments the score of a specified member in a sorted set by the increment value.
By passing a negative increment value, the score can be decreased by the corresponding amount, for example, ZINCRBY key -5 member
decreases the score of member
by 5.
When the key does not exist, or the member is not a part of the key, ZINCRBY key increment member
is equivalent to ZADD key increment member
.
An error is returned if the key is not of the sorted set type.
The score value can be an integer or a double precision floating point number.
Syntax
The basic syntax of the redis Zincrby command is as follows:
redis 127.0.0.1:6379> ZINCRBY key increment member
Available Versions
= 1.2.0
Return Value
The new score value of the member, represented as a string.
Example
redis> ZADD myzset 1 "one"
(integer) 1
redis> ZADD myzset 2 "two"
(integer) 1
redis> ZINCRBY myzset 2 "one"
"3"
redis> ZRANGE myzset 0 -1 WITHSCORES
1) "two"
2) "2"
3) "one"
4) "3"
redis>