Reputation: 110093
In the documentation, it strongly discourages the use of .keys()
in a production environment. What would be an alternative to the following:
r = Redis()
keys = r.keys('RT*')
for key in keys:
do_something()
Upvotes: 7
Views: 8426
Reputation: 16121
SCAN
is the recommended alternative for production usage.
redis-py includes a convenient SCAN
iterator for that purpose, so what you can do is:
r = Redis()
for key in r.scan_iter(match='RT*'):
print(key) # or do something
Upvotes: 16