您的位置:首页 > 数据库 > Redis

Redis命令-有序集合-zrevrank

2016-04-19 10:18 471 查看

 

原文

http://redis.io/commands/zrevrank

 

简介

Determine the index of a member in a sorted set, with scores ordered from high to low.

 

确定有序集合中成员的索引,按照分数从高到低的顺序。

 

语法

ZREVRANK key member

 

版本

Available since 2.0.0.

 

自2.0.0版本可用。

 

时间复杂度

Time complexity: O(log(N))

 

描述

Returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.

 

返回有序集合中成员的次序,按照分数从高到低。次序(或称为索引)是基于0的,意味着最高分数的成员的次序是0。

 

Use ZRANK to get the rank of an element with the scores ordered from low to high.

 

使用ZRANK获取元素的次序,按照分数由低到高排序。

 

返回值

If member exists in the sorted set, Integer reply: the rank of member.

If member does not exist in the sorted set or key does not exist, Bulk string reply: nil.

 

1)如果成员在有序集合中存在,返回成员的次序。
2)如果成员在有序集合中不存在,或者key不存在,返回nil。

 

例子

redis>  ZADD myzset 1 "one"
(integer) 1
redis>  ZADD myzset 2 "two"
(integer) 1
redis>  ZADD myzset 3 "three"
(integer) 1
redis>  ZREVRANK myzset "one"
(integer) 2
redis>  ZREVRANK myzset "four"
(nil)
redis>

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: