按顺序扫描redis排序集

按顺序扫描redis排序集,redis,node-redis,Redis,Node Redis,我正在使用节点redis连接到redis redis提供的zscan函数不按顺序返回元素。我想知道是否有一个javascript库可以帮助我做到这一点 您可以使用ZRANGE命令扫描已排序的集合。您只需记录已扫描的元素数量 // scan from the element with the smallest score (ascending order) var index = 0 var count = 10 ZRANGE key index index + count - 1 index +

我正在使用
节点redis
连接到redis


redis提供的
zscan
函数不按顺序返回元素。我想知道是否有一个
javascript
库可以帮助我做到这一点

您可以使用
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

使用
ZREVRANGE
命令,您还可以按降序扫描排序集。

您可以使用
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

使用
ZREVRANGE
命令,您还可以按降序扫描已排序的集合。

不确定为什么会被否决,这个答案是正确的谢谢!我想这一定是一项非常普通的任务,所以我希望其他人已经公开了这项任务:(不确定为什么这项被否决,这个答案是正确的,谢谢!我想这一定是一项非常普通的任务,所以我希望其他人已经公开了这项任务:(