पाठ 19 / 20
Python ऐप में रेडिस
redis-py से Python से Redis से जुड़ें और plain strings के साथ काम करने के लिए decode_responses उपयोग करें।
क्लाइंट इंस्टॉल करें
redis-py Python के लिए मानक, अच्छी तरह बना क्लाइंट है।
pip install redisकनेक्ट करें और उपयोग करें
decode_responses=True bytes की बजाय सीधी Python स्ट्रिंग लौटाता है — एक कम चीज़ बदलनी पड़ती है।
import redis
r = redis.Redis(host="localhost", port=6379, decode_responses=True)
r.set("greeting", "hello", ex=60)
print(r.get("greeting")) # hello