Reputation: 46
1+ billion keys in redis.
Now I want get ALL the keys in python.
partkeys = redisclient.keys("abcd*")
will be ok.
But
keys = redisclient.keys("ab*")
will raise ResponseError.
redis.exceptions.ResponseError: keys err
And
keys = redisclient.keys("*")
will raise a ConnectionError.
redis.exceptions.ConnectionError: Error 111 connecting demo.abcd.com:6397. Connection refused.
Any help?
Upvotes: 2
Views: 8313
Reputation: 2764
I suppose you use py-redis, use scan_iter
, then:
for k in redisclient.scan_iter(match='*'):
# Do something with k
# ...
As others noted, SCAN is only available since Redis 2.8.0
Upvotes: 2