zRemRangeByRank, zDeleteRangeByRank 命令/方法/函数

Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end].

移除key对应的有序集合中rank值介于start和stop之间的所有元素。start和stop均是从0开始的,并且两者均可以是负值。当索引值为负值时,表明偏移值从有序集合中score值最高的元素开始。例如:-1表示具有最高score的元素,而-2表示具有次高score的元素,以此类推。


Parameters

key

start: LONG

end: LONG


Return value

LONG The number of values deleted from the sorted set


Example

$redis->zAdd('key', 1, 'one');

$redis->zAdd('key', 2, 'two');

$redis->zAdd('key', 3, 'three');

$redis->zRemRangeByRank('key', 0, 1); /* 2 */

$redis->zRange('key', 0, -1, array('withscores' => TRUE)); /* array('three' => 3) */