zincrby.3valkey - Man Page
Increments the score of a member in a sorted set.
Synopsis
ZINCRBY
key increment member
Description
Increments the score of member
in the sorted set stored at key
by increment
. If member
does not exist in the sorted set, it is added with increment
as its score (as if its previous score was 0.0
). If key
does not exist, a new sorted set with the specified member
as its sole member is created.
An error is returned when key
exists but does not hold a sorted set.
The score
value should be the string representation of a numeric value, and accepts double precision floating point numbers. It is possible to provide a negative value to decrement the score.
Reply
Resp2
valkey-protocol(7) Bulk string reply: the new score of member as a double precision floating point number.
Resp3
valkey-protocol(7) Double reply: the new score of member.
Complexity
O(log(N)) where N is the number of elements in the sorted set.
Acl Categories
@fast @sortedset @write
History
- Available since: 1.2.0
Examples
127.0.0.1:6379> ZADD myzset 1 "one" (integer) 1 127.0.0.1:6379> ZADD myzset 2 "two" (integer) 1 127.0.0.1:6379> ZINCRBY myzset 2 "one" "3" 127.0.0.1:6379> ZRANGE myzset 0 -1 WITHSCORES 1) "two" 2) "2" 3) "one" 4) "3"
See Also
bzmpop(3valkey), bzpopmax(3valkey), bzpopmin(3valkey), zadd(3valkey), zcard(3valkey), zcount(3valkey), zdiff(3valkey), zdiffstore(3valkey), zinter(3valkey), zintercard(3valkey), zinterstore(3valkey), zlexcount(3valkey), zmpop(3valkey), zmscore(3valkey), zpopmax(3valkey), zpopmin(3valkey), zrandmember(3valkey), zrange(3valkey), zrangestore(3valkey), zrank(3valkey), zrem(3valkey), zremrangebylex(3valkey), zremrangebyrank(3valkey), zremrangebyscore(3valkey), zrevrank(3valkey), zscan(3valkey), zscore(3valkey), zunion(3valkey), zunionstore(3valkey)