Redis扫描不会遍历集合

Redis scan does not iterate all over the set

我想通过扫描将一个大的redis 集分成批次。迭代集合中的某些元素后,游标变为 0。假设集合长度为250000,sscan分页集合中大约70000个元素就结束了。 有谁知道为什么?

正如@Niloct 所说,有一些条件可以保证完全迭代: https://redis.io/commands/scan#scan-guarantees

A full iteration always retrieves all the elements that were present in the collection from the start to the end of a full iteration

当你迭代一个有过期时间的大集合时,你应该用count个数来控制迭代的速度。如果您为 count 传递较小的数字,则迭代会花费更多时间,这样,集合中的某些元素可能已经过期,因此您会错过它们。