How to store and retrieve a dictionary with redis

    # I have the dictionary my_dict
    my_dict = {
        'var1' : 5
        'var2' : 9
    r = redis.StrictRedis()

How would I store my_dict and retrieve it with redis. For example, the following code does not work.

    #Code that doesn't work
    r.set('this_dict', my_dict)  # to store my_dict in this_dict
    r.get('this_dict')  # to retrieve my_dict

You can do it by hmset (multiple keys can be set using hmset).

hmset("RedisKey", dictionaryToSet)

    import redis
    conn = redis.Redis('localhost')

    user = {"Name":"Pradeep", "Company":"SCTL", "Address":"Mumbai", "Location":"RCP"}

    conn.hmset("pythonDict", user)


    {'Company': 'SCTL', 'Address': 'Mumbai', 'Location': 'RCP', 'Name': 'Pradeep'}