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

'Get All Match Keys' returns partial list #40

Open
dzvancuks opened this issue Jun 11, 2024 · 0 comments
Open

'Get All Match Keys' returns partial list #40

dzvancuks opened this issue Jun 11, 2024 · 0 comments

Comments

@dzvancuks
Copy link

In case I want to get long list of keys then Get All Match Keys will fail my test.

    # Set To Redis    some other keys so that DB would have data before cycle below

    FOR    ${counter}    IN RANGE    100
        Set To Redis    ${REDIS CONN}    MyKey_${counter}    ${counter}
    END
    @{key_list}=    Get All Match Keys    ${REDIS CONN}    MyKey_*    count=100
    ${count}         Get length          ${key_list}
    Should Be Equal As Integers    ${count}    100

==============================================================================
TEST                                                                  | FAIL |
84 != 100
------------------------------------------------------------------------------
Tests.MyTests                                                         | FAIL |
1 test, 0 passed, 1 failed
==============================================================================

And this is totally expected. Scan do not guarantee that it will get all keys in one go. That is count=100 means that Redis will atomically parse 100 keys and return current position for next scan operation:

redis-cli

> scan 0 match MyKey_* count 100
1) "88"
2)  1) "MyKey_35"
    2) "MyKey_54"
    3) "MyKey_68"
...

Scan operation should be continued until first value of return becomes 0 again (1) "88" should become 0)

See https://redis.io/docs/latest/commands/scan/

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

1 participant