Redis命令-有序集合-zrevrangebyscore

原文

http://redis.io/commands/zrevrangebyscore

简介

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

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

语法

ZREVRANGEBYSCORE key max min [WITHSCORES] [LIMIT offset count]

版本

Available since 2.2.0.

自2.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 being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).

O(log(N)+M):N是有序集合中元素的数量,M是返回的元素的数量。如果M是常量,你可以认为时间复杂度为O(log(N))。

描述

Returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min). In contrary to the default ordering of sorted sets, for this command the elements are considered to be ordered from high to low scores.

返回有序集合中分数在max到min之间(包括分数等于max和min的元素)的所有元素。这个命令是按分数从高到低排序的。

The elements having the same score are returned in reverse lexicographical order.

相同分数的元素按照词典顺序倒序返回。

Apart from the reversed ordering, ZREVRANGEBYSCORE is similar to ZRANGEBYSCORE.

除了颠倒排序,ZREVRANGEBYSCORE与ZRANGEBYSCORE类似。

返回值

Array reply: list of elements in the specified score 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>  ZREVRANGEBYSCORE myzset +inf -inf
1) "three"
2) "two"
3) "one"
redis>  ZREVRANGEBYSCORE myzset 2 1
1) "two"
2) "one"
redis>  ZREVRANGEBYSCORE myzset 2 (1
1) "two"
redis>  ZREVRANGEBYSCORE myzset (2 (1
(empty list or set)
redis>

猜你喜欢

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