9951 explained code solutions for 126 technologies


python-redisGet dict from Redis


We'll use Redis hash structure to save dicts:

r = redis.Redis()
dict = r.hgetall('dict')ctrl + c
redis.Redis

connect to Redis server

hgetall

gets Redis hash data and returns a dict

'dict'

name of the hash in Redis


Usage example

import redis

dict = {'name': 'Donald', 'age': 102}

r = redis.Redis()
r.hmset('d', dict)

print(r.hgetall('d'))
output
{b'name': b'Donald', b'age': b'102'}