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

Redis命令-有序集合-zremrangebyrank

2016-04-21 22:03 579 查看

 

原文

http://redis.io/commands/zremrangebyrank

 

简介

Remove all members in a sorted set within the given indexes.

 

从有序集合中删除指定索引范围内的所有成员。

 

语法

ZREMRANGEBYRANK key start stop

 

版本

Available since 2.0.0.

 

自2.0.0版本可用。

 

时间复杂度

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

 

O(M*log(N)):N是有序集合中元素的数量,M是要删除的元素的数量。

 

描述

Removes all elements in the sorted set stored at key with rank between start and stop. Both start and stop are 0 -based indexes with 0 being the element with the lowest score. These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score. For example: -1 is the element with the highest score, -2 the element with the second highest score and so forth.

 

从有序集合中删除索引在start和stop之间的所有元素。start和stop都是基于0的索引,0表示分数最低的元素。这些索引可以是负数,表示从分数最高的元素计算偏移。例如:-1表示分数最高的元素,-2表示分数次高的元素等等。

 

返回值

Integer reply: the number of elements removed.

 

删除的元素数量。

 

例子

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

 

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