Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanermita/ece0ea1fa5428d9adc06233c572b8cca to your computer and use it in GitHub Desktop.
Save ryanermita/ece0ea1fa5428d9adc06233c572b8cca to your computer and use it in GitHub Desktop.
dict_object = {
"name": "John Doe",
"social_media_accounts": ["facebook", "twitter", "Instagram"],
"language_proficiency": {
"Python": "9/10",
"Javascript": "7/10",
"Ruby": "8/10"
}
}
type(dict_object) # dict
type(dict_object["social_media_accounts"]) # dict
type(dict_object["language_proficiency"]) # list
# cache dict_object as redis hash
app.redis_connection.hmset("your_unique_key", dict_object)
# fetch cached data (hash) from redis
cached_data = app.redis_connection.hgetall("your_unique_key")
type(cached_data) # dict
type(cached_data["social_media_accounts"]) # string
type(cached_data["language_proficiency"]) # string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment