Skip to content

Please explain why I got infinite loop. #190

Answered by aembke
goshleg asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ghashy,

SCAN works by repeatedly sending a SCAN <cursor> ... command to the server with an updated cursor after each page.

In the first example you're sending a new SCAN 0 ... call with a fresh starting cursor on each iteration in the while loop, and the second one is properly paging through the results. Or in other words - in the first example you're calling both scan and try_next on each loop iteration, but in the second you're only calling try_next on each iteration.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@goshleg
Comment options

Answer selected by goshleg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants