我正在使用 node 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
命令,您还可以按降序扫描已排序的集合。
关于redis - 按顺序扫描redis排序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42898374/