A Redis connection pool manager with asyncio support.
Project description
Redis Manager
Features
- Asynchronous & High-Performance: Non-blocking operations with
asyncio. - Auto-Healing Connection Pools: Recover from failures without service restarts.
- Context Manager: Prevent resource leaks in high-concurrency systems.
- Real-Time Monitoring: Prometheus metrics for insights and debugging.
- Redis Cluster Support: Simplified handling of distributed nodes.
Quickstart
Install Redis Manager:
pip install redis-manager
Example Code:
from redis_manager.redis_manager import RedisManager
async def main():
manager = RedisManager(connection_pools_per_node_at_start=2)
await manager.add_node_pool("redis://localhost")
manager.start_cleanup()
# Note: The RedisManager can be wrapped in a try/catch block to gracefully handle exceptions
# such as connection errors or unavailability of Redis nodes.
async with manager.get_client("redis://localhost") as client:
await client.set("key", "value")
value = await client.get("key")
print(value)
# Stop tasks and close pools
manager.stop_health_checks()
manager.stop_cleanup()
await manager.close_all_pools()
Architecture Diagram
graph TD
subgraph RedisManager
A[Connection Pools] -->|Healthy Connections| B[Redis Nodes]
A -->|Health Check Task| C[Periodic Health Checks]
A -->|Cleanup Task| D[Idle Connection Cleanup]
end
B -->|Commands| E[Redis Server]
subgraph Monitoring
A -->|Metrics| F[Prometheus Exporter]
F --> G[Prometheus]
G --> H[Grafana Dashboard]
end
Documentation
- ➡️ Learn More About Architecture
- ➡️ Why Redis Manager?
- ➡️ Usage Examples
- ➡️ API Documentation
- ➡️ Packaging
Acknowledgments
- Redis: The powerful in-memory data structure store used for fast data storage and retrieval.
- Asyncio: Python's asynchronous programming framework, enabling efficient and scalable async operations.
- Bitnami Redis Cluster Docker Images: Used in testing and integration for seamless containerized Redis cluster setups.
- Prometheus: Open-source monitoring and alerting toolkit for metrics collection and visualization.
- Grafana: The leading open-source analytics and interactive visualization tool, providing rich dashboards for monitoring Redis performance and related metrics.
Changelog
Detailed changelog in CHANGELOG.md.
License
Licensed under the MIT License. See LICENSE file for more details.
Contributing
We welcome contributions! Please see our Contributing Guide and Code of Conduct to get started.
Initially Developed by Youssef Khaya
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redis_manager-0.1.1.tar.gz.
File metadata
- Download URL: redis_manager-0.1.1.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b06504811d228874cab04fa1172f59de04f3d11e59a899407d012eb1dd5c4331
|
|
| MD5 |
694edc3bc3a3b204c6a7f07b53728489
|
|
| BLAKE2b-256 |
768b696609292055a6887bdab9f4b17bca811c80568415844169f518109bbdb3
|
File details
Details for the file redis_manager-0.1.1-py3-none-any.whl.
File metadata
- Download URL: redis_manager-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d80f0d2b4ecab77bd367812275bdb57068baeba8723b898e415e6f873f0220f5
|
|
| MD5 |
94e4248589c90b9812f577cf0c8b7087
|
|
| BLAKE2b-256 |
13b36b165a7ad27f913e786d21b3482f93a5f7965a75bd49af875ef8ab3a5104
|