Redis命令-有序集合-zrevrange

原文

http://redis.io/commands/zrevrange

简介

Return a range of members in a sorted set, by index, with scores ordered from high to low.

根据索引返回有序集合中一定范围内的成员,按照分数从高到低排序。

语法

ZREVRANGE key start stop [WITHSCORES]

版本

Available since 1.2.0.

自1.2.0版本可用。

时间复杂度

Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements returned.

O(log(N)+M):N是有序集合中元素的数量,M是返回的元素的数量。

描述

Returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.

返回有序集合中指定范围内的元素。这些元素被认为是按照分数从高到低排序。对于相同分数的元素,按照词典顺序倒序。

Apart from the reversed ordering, ZREVRANGE is similar to ZRANGE.

除了颠倒顺序,ZREVRANGE与ZRANGE类似。

返回值

Array reply: list of elements in the specified range (optionally with their scores).

Array:指定范围的元素列表。

例子

redis>  ZADD myzset 1 "one"
(integer) 1
redis>  ZADD myzset 2 "two"
(integer) 1
redis>  ZADD myzset 3 "three"
(integer) 1
redis>  ZREVRANGE myzset 0 -1
1) "three"
2) "two"
3) "one"
redis>  ZREVRANGE myzset 2 3
1) "one"
redis>  ZREVRANGE myzset -2 -1
1) "two"
2) "one"
redis>

猜你喜欢

转载自gitzhangyl.iteye.com/blog/2290416