Redis命令-有序集合-zincrby

 

原文

http://redis.io/commands/zincrby

 

简介

Increment the score of a member in a sorted set.

 

增加有序集合中一个成员的分数。

 

语法

ZINCRBY key increment member

 

版本

Available since 1.2.0.

 

自1.2.0版本可用。

 

时间复杂度

Time complexity: O(log(N)) where N is the number of elements in the sorted set.

 

O(log(N)):N是有序集合中元素的数量。

 

描述

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.

 

把有序集合中指定成员member的分数增加increment。如果有序集合中不存在该成员,这个成员会被添加到有序集合中,并把increment作为它的分数。如果key不存在,一个新的有序集合被创建,指定的成员作为新有序集合的唯一成员。

 

An error is returned when key exists but does not hold a sorted set.

 

当key存在但不是有序集合时,返回错误。

 

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.

 

分数值score应该是数字值的字符串表示,可以接受双精度浮点数。可以提供负值来减少分数。

 

返回值

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

 

Bulk string:以字符串形式表示的成员的新分数(双精度浮点数)。

 

例子

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>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值