-
Hello, and thanks for this amazing crate! while let Some(mut page) = redis_client
.scan("*", Some(10), None)
.try_next()
.await
.unwrap()
{
if let Some(keys) = page.take_results() {
dbg!(keys);
}
page.next().unwrap();
} But if I extract let mut scan = redis_client.scan("*", Some(10), None);
while let Some(mut page) = scan.try_next().await.unwrap() {
if let Some(keys) = page.take_results() {
dbg!(keys);
}
page.next().unwrap();
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ghashy, SCAN works by repeatedly sending a In the first example you're sending a new |
Beta Was this translation helpful? Give feedback.
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 bothscan
andtry_next
on each loop iteration, but in the second you're only callingtry_next
on each iteration.