redis ZRANK command
Translation results:
rank
英[ræŋk] 美[ræŋk]
n.Military rank; class, level; order, order; rank
vt .& vi. Arrange, make it horizontally; classify...
vt. Arrange; exceed, be higher than; rank...
vi. Located; make it horizontally; complain; Fault-finding, exposing scars
adj. Disgusting; extreme; lush; stinking
Third person singular: ranks Plural: ranks Present participle: ranking Past tense: ranked Past participle: ranked Comparison Level: ranker Highest level: rankest
redis ZRANK commandsyntax
Function: Returns the ranking of member in the ordered set key. The members of the ordered set are arranged in order of increasing score value (from small to large).
Syntax: ZRANK key member
Description: The ranking is based on 0, that is to say, the member with the smallest score value is ranked 0. Use the ZREVRANK command to get the ranking of members in descending order of score (from large to small).
Available versions: >= 2.0.0
Time complexity: O(log(N))
Return: If member is a member of the ordered set key, return the ranking of member. If member is not a member of the ordered set key, return nil.
redis ZRANK commandexample
redis> ZRANGE salary 0 -1 WITHSCORES # 显示所有成员及其 score 值 1) "peter" 2) "3500" 3) "tom" 4) "4000" 5) "jack" 6) "5000" redis> ZRANK salary tom # 显示 tom 的薪水排名,第二 (integer) 1