Created
January 2, 2019 01:27
-
-
Save lppier/7cd007f5fa6af40ef1b22bd236f40f09 to your computer and use it in GitHub Desktop.
Redis Retrieving and Putting a Python Dictionary in Redis
This file contains 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
import redis | |
import json | |
# Retrieve Redis Stored Values, if any for faster processing | |
anc_dict_320 = {} | |
r = redis.Redis(host='localhost', port=6379, db=0) | |
json_str_320 = r.get("anc_dict_320") | |
if json_str_320 is not None: | |
anc_dict_320 = json.loads(json_str_320) | |
print(anc_dict_320) | |
# Put data in redis database | |
if len(anc_dict_320) > 0: | |
r.set("anc_dict_320", json.dumps(anc_dict_320)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment