Lesson 19 / 20
Redis in a Python App
Connect to Redis from Python with redis-py and use decode_responses to work with plain strings.
Install the client
redis-py is the standard, well-maintained client for Python.
pip install redisConnect & use it
decode_responses=True returns plain Python strings instead of bytes — one less thing to convert.
import redis
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
r.set("greeting", "hello", ex=60)
print(r.get("greeting")) # hello