Created
August 19, 2018 01:28
-
-
Save ryanermita/d26bd0e0b5658fa8811981d508696f99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dict_object = { | |
"name": "John Doe", | |
"social_media_accounts": ["facebook", "twitter", "Instagram"], | |
"language_proficiency": { | |
"Python": "9/10", | |
"Javascript": "7/10", | |
"Ruby": "8/10" | |
} | |
} | |
# convert your dict object to string | |
stringified_dict_obj = json.dumps(dict_object) | |
type(stringified_dict_obj) # str | |
# cache stringified dict_object | |
app.redis_connection.set("your_unique_key", stringified_dict_obj) | |
# fetch cached data (string) from redis | |
cached_data = app.redis_connection.get("your_unique_key") | |
type(cached_data) # str | |
# convert your string cached data to object(dict/JSON) | |
cached_data_as_dict = json.loads(cached_data) | |
type(cached_data_as_dict) # dict | |
type(cached_data_as_dict["social_media_accounts"]) # list | |
type(cached_data_as_dict["language_proficiency"]) # dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment