redis-py
Official Python client for Redis — the in-memory data structure store. redis-py provides sync and async (aioredis integrated into redis-py 4.x+) interfaces to all Redis data types (strings, hashes, lists, sets, sorted sets, streams), pub/sub, Lua scripting, and Redis Cluster/Sentinel. The standard Python Redis client used across frameworks including Django cache backend, Celery broker, and FastAPI caching.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Redis AUTH password required in production. TLS connection (redis+ssl://) for cloud deployments. Redis ACL in Redis 6+ for user-level permissions. Never expose Redis port publicly — internal network only.
⚡ Reliability
Best When
You need fast in-memory caching, session storage, pub/sub messaging, or rate limiting with the standard Python Redis client.
Avoid When
You need persistent ACID-compliant storage — Redis is a cache/message broker, not a primary database.
Use Cases
- • Cache expensive database queries or API responses with TTL-based expiration using Redis strings and hashes
- • Implement session storage for web applications with Redis as the session backend
- • Use Redis pub/sub for real-time event broadcasting between Python services
- • Build rate limiting using Redis atomic increment and expiry (INCR + EXPIRE pattern)
- • Use async redis client (AsyncRedis) with FastAPI or async Python services for non-blocking Redis access
Not For
- • Persistent data storage requiring ACID guarantees — Redis is in-memory with optional persistence
- • Complex relational queries — use PostgreSQL or MySQL; Redis excels at key-value and simple data structures
- • Applications that can't afford Redis infrastructure — Redis requires a running Redis server
Interface
Authentication
Redis AUTH password passed in connection URL or redis.Redis(password=). Redis 6+ ACL user authentication also supported.
Pricing
redis-py library is free. Redis server is SSPL licensed (open source with enterprise restrictions). Redis Cloud is the managed offering.
Agent Metadata
Known Gotchas
- ⚠ redis-py 4.x merged aioredis — use redis.asyncio.Redis for async access; old import from aioredis package no longer works with new versions
- ⚠ All Redis values are stored as bytes — redis-py returns bytes by default; use decode_responses=True in Redis() constructor to auto-decode to strings
- ⚠ Connection pooling is used by default (ConnectionPool) — redis.Redis() creates a pool, not a single connection; never close the pool in the middle of requests
- ⚠ Pipeline commands are buffered and sent atomically — if one command fails, others still execute; pipeline doesn't rollback; use MULTI/EXEC transactions for all-or-nothing semantics
- ⚠ Redis KEYS pattern command is O(N) and blocks server — never use KEYS in production; use SCAN for non-blocking iteration over keys
- ⚠ TTL returns -1 for keys without expiry, -2 for non-existent keys — agents must handle both cases; not distinguishing causes bugs when checking expiry
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for redis-py.
Scores are editorial opinions as of 2026-03-06.