A universal Redis client factory for Python — just pass a single connection string and get back a ready-to-use redis.Redis instance (both sync and async).
- Universal Interface: Single API for standalone, Sentinel, and Cluster modes
- Automatic Detection: Detects deployment mode from URI
- Async Support: Full async/await support
- Connection Pooling: Automatic pool management
- SSL Support: Built-in SSL/TLS support
from python_redis_factory import get_redis_client
from redis import Redis
from redis.asyncio import Redis as AsyncRedis
# Standalone Redis (sync)
client: Redis = get_redis_client("redis://localhost:6379")
# Standalone Redis (async)
async_client: AsyncRedis = get_redis_client("redis://localhost:6379", async_client=True)
# Sentinel (sync)
sentinel_client: Redis = get_redis_client("redis+sentinel://sentinel1:26379/mymaster")
# Sentinel (async)
async_sentinel_client: AsyncRedis = get_redis_client("redis+sentinel://sentinel1:26379/mymaster", async_client=True)
# Cluster (sync)
cluster_client: Redis = get_redis_client("redis+cluster://node1:7000,node2:7001")
# Cluster (async)
async_cluster_client: AsyncRedis = get_redis_client("redis+cluster://node1:7000,node2:7001", async_client=True)
# SSL (sync)
ssl_client: Redis = get_redis_client("rediss://localhost:6379")
# SSL (async)
async_ssl_client: AsyncRedis = get_redis_client("rediss://localhost:6379", async_client=True)pip install python-redis-factory# Install dependencies
make install
# Run tests
make test-parallel
# Run quality checks
make ci
# Show all commands
make help- Examples - Comprehensive examples with Docker Compose
- Release Guide - How to make releases
- Release Checklist - Pre-release checklist
# Standalone
redis://[user:password@]host[:port][/db]
rediss://[user:password@]host[:port][/db] # SSL
# Sentinel
redis+sentinel://[password@]sentinel1:port,sentinel2:port/service_name
# Cluster
redis+cluster://[password@]node1:port,node2:port