9952 explained code solutions for 126 technologies

python-redisIterate through Redis keys

r = redis.Redis()

for k in r.scan_iter('*'):
  r.get(k)ctrl + c

connect to Redis server


returns iterator with all keys matching specified pattern


pattern to search for keys (all keys in our case)


gets value by key from Redis (just random example of something to do with the key)

Usage example

import redis

r = redis.Redis()

for k in r.scan_iter("*"):
  print(k, ': ', r.get(k))
b'a' :  b'1'
b'bool' :  b'1'
b'd1' :  b'{"name": "Donald", "family": {"wife": "Melany"}}'
b'test' :  b'1'
b'c' :  b'3'
b'counter1' :  b'5'