无涯教程-Redis - ZINCRBY 命令函数

84 阅读1分钟

Redis ZINCRBY 命令按增量递增存储在键(key)中的排序集中元素的分数。

ZINCRBY - 返回值

返回元素的新分数(双精度浮点数),表示为字符串。

ZINCRBY - 语法

以下是Redis ZINCRBY 命令的基本语法。

redis 127.0.0.1:6379> ZINCRBY KEY INCREMENT MEMBER

ZINCRBY - 示例

redis 127.0.0.1:6379> ZADD myset 1 "hello" 
(integer) 1 
redis 127.0.0.1:6379> ZADD myset 1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> ZINCRBY myzset 2 "hello" 
(integer) 3 
redis 127.0.0.1:6379> ZRANGE myzset 0 -1 WITHSCORES 
1) "foo" 
2) "2" 
3) "hello" 
4) "3"

参考链接

www.learnfk.com/redis/sorte…