0

Using redis python client, I want to list all of the keys with a certain pattern using scan_iter().

import redis
r = redis.StrictRedis(host=host, port=port, db=db)
count = 0
for key in r.scan_iter(match='pattern'):
    count += 1
    print(key)
print(count)

Running the above code will output 2 different number of keys and I am getting them alternately. Why am I getting those 2 different output? Is there any session or transaction involved in the connnection?

1 Answer 1

2

The reason why I am getting different result is that I have 2 redis containers running. The python client must be connecting to different redis instance every connection.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.