पाठ 17 / 18
Python ऐप में रेडिस
redis-py क्लाइंट से Python से रेडिस से बात करें।
क्लाइंट इंस्टॉल करें
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