您可以使用该ZRANGE命令来扫描已排序的集合。您只需要记录已扫描的元素数即可。
// scan from the element with the smallest score (ascending order)
var index = 0
var count = 10
ZRANGE key index index + count - 1
index += count
ZRANGE key index index + count - 1
// until all elements have been scanned
Run Code Online (Sandbox Code Playgroud)
使用该ZREVRANGE命令,您还可以按降序扫描排序的集合。