redis-py

The official Python client for Redis, with sync, asyncio, cluster, and Sentinel support.

SDK
PyPI
v8.1.0
13,652 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
95 /100 Excellent
Development Activity 100
Maintenance 84
Community 96
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
87 /100 Excellent
Architecture 90
Code Quality 88
Innovation 82
Learning Curve 85

redis-py is the official Python client library for Redis, maintained by Redis Inc. It implements the full Redis command surface for strings, hashes, sets, sorted sets, streams, and pub/sub, alongside module command mixins for RedisJSON, RediSearch, TimeSeries, Bloom filters, and vector sets.

It ships both a synchronous, threading-based client and an asyncio-native client under redis.asyncio that share the same API, plus dedicated RedisCluster and Sentinel classes for sharded and high-availability deployments. Connection pooling, pipelining, Lua scripting, client-side caching, and configurable RESP2/RESP3 wire protocol support round out the package.

What You Get

  • Full command coverage — every core Redis command (strings, hashes, sets, sorted sets, streams, pub/sub, scripting) plus JSON, Search, TimeSeries, Bloom, and vector-set module commands.
  • Sync and async clients — a threading-based redis.Redis client and an asyncio-native redis.asyncio.Redis client sharing the same API surface.
  • Cluster and Sentinel support — RedisCluster for sharded deployments with MOVED/ASK redirection, and Sentinel for automatic primary discovery and failover.
  • Connection pooling and pipelining — configurable ConnectionPool/BlockingConnectionPool, MULTI/EXEC pipelines, and optional hiredis-accelerated response parsing.
  • RESP3 and client-side caching — opt-in RESP3 protocol support with built-in client-side caching and a documented migration path away from legacy RESP2 response shapes.

Common Use Cases

  • Caching layer for a web application - store computed API responses or session data in Redis with TTLs to cut database load.
  • Distributed locks and rate limiting - use redis-py’s Lock primitive and atomic command support to coordinate work across multiple app instances.
  • Pub/Sub messaging between services - fan out real-time events to subscribers over Redis channels without standing up a separate message broker.
  • Vector search and RAG pipelines - use the vector-set and RediSearch command mixins to store embeddings and run similarity queries directly against Redis.

Under The Hood

Architecture: redis-py structures the client around a small set of composable layers: redis/connection.py (3,868 lines) implements Connection, ConnectionPool, and BlockingConnectionPool, handling socket/TLS setup, RESP2/RESP3 parsing via _parsers/, and reconnection/backoff logic from redis/retry.py and redis/backoff.py. redis/client.py (2,279 lines) defines Redis/StrictRedis, which mix in command implementations from redis/commands/core.py (12,500+ lines) plus module-specific mixins under redis/commands/{json,search,bf,timeseries,vectorset}/. redis/cluster.py (5,000+ lines) reimplements slot-aware routing and MOVED/ASK redirection on top of the same connection layer, and redis/sentinel.py adds Sentinel-based primary discovery. The entire sync surface is mirrored under redis/asyncio/ with asyncio-native connection and client classes sharing the same command mixins, so switching between sync and async code paths requires minimal application-level changes.

Tech Stack: The library targets Python 3.10+ (per pyproject.toml) and ships as a pure-Python package built with hatchling; runtime dependencies are minimal — only async-timeout on older Python versions — with everything else (hiredis for compiled response parsing, xxhash, cryptography/pyopenssl/requests for OCSP, PyJWT, pybreaker, OpenTelemetry) declared as optional extras (e.g. pip install redis[hiredis]), keeping the core install lightweight. Type checking is configured via .mypy.ini, and the package ships a py.typed marker for downstream type checkers.

Code Quality: Test coverage is substantial: tests/ contains 147 files and roughly 2,769 test functions covering standalone, cluster, Sentinel, asyncio, and module (JSON/Search/TimeSeries) command paths, run via pytest with markers like fixed_client to control fixture reuse. Error handling is centralized in redis/exceptions.py, which defines a typed RedisError hierarchy (ConnectionError, TimeoutError, AuthenticationError, etc.) carrying a categorical error_type and optional status_code, giving callers a consistent way to distinguish network, TLS, auth, and server errors. CI under .github/workflows/ (including a dedicated integration.yaml) runs the suite against real Redis server versions.

API Design: The public API mirrors Redis’s own command vocabulary directly (r.set, r.hset, r.ft().search()), so developers already familiar with Redis need little translation; a basic Redis(host=..., port=..., db=...) call after pip install redis is enough to get started, with ConnectionPool and pipeline() available but not required. Recent releases introduced a deliberate migration path — legacy_responses and protocol=3 flags let existing applications keep RESP2-shaped Python responses while opting into RESP3 wire behavior gradually, documented explicitly in the README rather than forced as a breaking change. The tradeoff is real surface-area complexity: client.py and cluster.py are each thousands of lines, and changes like the client-side default search dialect are called out as needing care when upgrading.

Used by 39 apps in this directory

Python
71%
MIT

Langflow

AI Agents · AI Development

155,973

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
64
Dependency
Built with
Python 71%
TypeScript 21%
Updated 5 days ago
Python
53%
AGPL 3.0

LearnHouse

CMS · Learning Management

2,413

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
90
Repo Health
77
Technical
65
Dependency
Built with
Python 53%
TypeScript 45%
Updated 5 days ago
Python
38%
Other

Open WebUI

AI Agents · AI Assistants

156,607

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
92
Repo Health
75
Technical
66
Dependency
Built with
Python 38%
Svelte 35%
JavaScript 19%
Updated 5 days ago
TypeScript
92%
Other

OpenHands

AI Code Assistants · AI Development

91,695

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 92%
Updated 6 days ago
TypeScript
54%
Other

OpenReplay

Analytics

13,042

Self-hosted session replay and product analytics suite that lets you see exactly what users do on your web app — without sending data to third parties.

View details
91
Repo Health
77
Technical
66
Dependency
Built with
TypeScript 54%
Go 13%
Updated 6 days ago
Python
39%
Apache 2.0

OpenSandbox

Developer Tools · Security

16,116

Secure, fast, and extensible sandbox runtime for AI agents with multi-language SDKs and Docker/Kubernetes runtimes.

View details
85
Repo Health
81
Technical
70
Dependency
Built with
Python 39%
Go 36%
Updated 5 days ago
Go
71%
Apache 2.0

OSV.dev

Security

3,001

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
87
Repo Health
82
Technical
66
Dependency
Built with
Go 71%
Python 19%
Updated 6 days ago
TypeScript
58%
MIT

pad.ws

Collaboration · Design Tools

4,206

A browser-based whiteboard that doubles as a full development environment, letting you draw and code in the same canvas.

View details
37
Repo Health
61
Technical
78
Dependency
Built with
TypeScript 58%
Python 31%
SCSS 10%
Updated 1 years ago
Python
63%
GPL 3.0

Paperless-ngx

Bookmarks Archiving

47,038

Turn your paper pile into a searchable digital archive with OCR, AI classification, and automated workflows — all running on your own server.

View details
91
Repo Health
88
Technical
67
Dependency
Built with
Python 63%
TypeScript 28%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers