修改本页

Redis 命令 客户端 文档 社区 下载 问题 支持 许可

ZINCRBY key increment member

相关命令

Available since 1.2.0.

时间复杂度: O(log(N)) where N is the number of elements in the sorted set.

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.

返回值

Bulk string reply: the new score of member (a double precision floating point number), represented as string.

例子

redis> ZADD myzset 1 "one"

  1. (integer) 1

redis> ZADD myzset 2 "two"

  1. (integer) 1

redis> ZINCRBY myzset 2 "one"

  1. "3"

redis> ZRANGE myzset 0 -1 WITHSCORES

  1. 1) "two"
  2. 2) "2"
  3. 3) "one"
  4. 4) "3"
redis>

Comments powered by Disqus

This website is open source software developed by Citrusbyte.

The Redis logo was designed by Carlos Prioglio. See more credits.

Sponsored by Redis Support