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?

jeicoo
  • 83
  • 1
  • 10

1 Answers1

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.

jeicoo
  • 83
  • 1
  • 10