Skip to content

Instantly share code, notes, and snippets.

Created Dec 19, 2018
What would you like to do?
Redis example
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
# Generate the connection
r = redis.Redis(host='', 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment