Redis Zincrby Command

Redis Sorted Set

The Redis Zincrby command adds the increment to the score of the specified member in the sorted set.

You can pass a negative increment to subtract the corresponding value from the score. For example, ZINCRBY key -5 member subtracts 5 from the score of member.

When the key does not exist, or the member is not a member of the key, ZINCRBY key increment member is equivalent to ZADD key increment member.

When the key is not of a sorted set type, an error is returned.

Score values can be integers or double-precision floating-point numbers.

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.

Examples

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> 

Redis Sorted Set

Other Extensions