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/
In case I want to get long list of keys then
Get All Match Keyswill fail my test.And this is totally expected. Scan do not guarantee that it will get all keys in one go. That is
count=100means that Redis will atomically parse 100 keys and return current position for next scan operation:Scan operation should be continued until first value of return becomes
0again (1) "88"should become0)See https://redis.io/docs/latest/commands/scan/