Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with SCAN or am I doing this wrong #2673

Closed
allanwax opened this issue Jul 14, 2015 · 4 comments
Closed

Problem with SCAN or am I doing this wrong #2673

allanwax opened this issue Jul 14, 2015 · 4 comments

Comments

@allanwax
Copy link

This is strange as I've used scan and it seems to work fine other than this case. The problem is that keys will return values but scan won't. The environment is redis cluster 3.0.2.

10.11.14.83:17000> keys DCC*
  1) "DCC:sports::football"
  2) "DCC:apparel::custom tees"
  3) "DCC:internet::peer to peer"
  4) "DCC:apparel::maternity"
  5) "DCC:food and drink::gourmet"
...
103) "DCC:social networking::tools"
104) "DCC:news::environment"
105) "DCC:education::medical billing"
106) "DCC:real estate::general"
107) "DCC:shopping::coupons"
10.11.14.83:17000> scan 0 match DCC* count 20
1) "16384"
2) (empty list or set)

My expectation is that scan will return the same content as keys in chunks of 20 and not necessarily in the same order. Also that the new scan starting value would be 0 if it did not find any keys. I did try repeatedly using the returned value to see if more keys would come but it always returned a new scan number and an empty list.

Am I using scan incorrectly?

@antirez
Copy link
Contributor

antirez commented Jul 14, 2015

Hello, yes you are using SCAN incorrectly ;-)
After the call, the cursor returned is non-zero, but 16384, so you have to call scan again with this cursor, and so on, until the cursor drops to 0, to signal the iteration ended.

@allanwax
Copy link
Author

This is what I tried repeatedly and new scan offsets kept coming, but no keys came. Why does the scan return nothing repeatedly. Or perhaps the question is if there are keys available, shouldn't scan return at least 1?

@antirez
Copy link
Contributor

antirez commented Jul 14, 2015

It checks a few keys per iteration, but none matched your pattern. The more you use a pattern with few keys compared to the total amount of keys, the less keys will be returned each iteration. Even zero at all. But you should keep iterating while all the keys are found for the pattern, and zero is returned as new cursor.

@antirez antirez closed this as completed Jul 14, 2015
@allanwax
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants