Back to snippets

redis_py_quickstart_set_and_get_string_key.py

python

Connects to a local Redis instance, sets a string key, and retrieves it.

19d ago9 linesredis.io
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