Created
December 19, 2018 17:52
-
-
Save oldarmyc/e1048916d64603ceb683c9bcadb49532 to your computer and use it in GitHub Desktop.
Redis example
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
""" | |
Connecting to Redis server | |
Install the pip package for python to use for connecting to Redis | |
pip install redis | |
""" | |
# Import the library | |
import redis | |
queried_value = None | |
try: | |
# Generate the connection | |
r = redis.Redis(host='support-redis.dev.anaconda.com', port=6379) | |
# Set and retrieve the same key | |
r.set('test_key', 'This is a test value for showing redis connectivity') | |
queried_value = r.get('test_key') | |
except Exception as e: | |
print(f'Unable to connect or execute commands on Redis server: {e}') | |
# Print out queried value | |
print(queried_value.decode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment