zRange 命令/方法/函数

Returns a range of elements from the ordered set stored at the specified key, with values in the range [start, end]. start and stop are interpreted as zero-based indices: 0 the first element, 1 the second ... -1 the last element, -2 the penultimate ...

取得特定范围内的排序元素,0代表第一个元素,1代表第二个以此类推。-1代表最后一个,-2代表倒数第二个...


Parameters

key

start: long

end: long

withscores: bool = false


Return value

Array containing the values in specified range.


Example

$redis->zAdd('key1', 0, 'val0');

$redis->zAdd('key1', 2, 'val2');

$redis->zAdd('key1', 10, 'val10');

$redis->zRange('key1', 0, -1); /* array('val0', 'val2', 'val10') */


// with scores

$redis->zRange('key1', 0, -1, true); /* array('val0' => 0, 'val2' => 2, 'val10' => 10) */