English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Zincrby Command

Redis Sorted Sets (sorted set)

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

You can pass a negative value increment to subtract the corresponding value from the score, such as ZINCRBY key -5 member, is to subtract the score value of member 5 .

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

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

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 Version

>= 1.2.0

Return Value

The new score value of the member, represented as a string.

Online 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 Sets (sorted set)