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()
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.