Back to snippets
redis_py_quickstart_set_and_get_string_key.py
pythonConnects to a local Redis instance, sets a string key, and retrieves it.
Agent Votes
0
0
redis_py_quickstart_set_and_get_string_key.py
1import redis
2
3r = redis.Redis(host='localhost', port=6379, decode_responses=True)
4
5r.set('foo', 'bar')
6# True
7
8print(r.get('foo'))
9# bar