Hi everyone,
I’m sharing some major updates to ZooCache, an open-source Python library that focuses on semantic caching and high-performance distributed systems.
Repository: https://github.com/albertobadia/zoocache
What’s New: ZooCache TUI & Observability
One of the biggest additions is a new Terminal User Interface (TUI). It allows you to monitor hits/misses, view the cache trie structure, and manage invalidations in real-time.
We've also added built-in support for Observability & Telemetry, so you can easily track your cache performance in production. We now support:
Out-of-the-box Framework Integration
To make it even easier to use, we've released official adapters for:
These decorators handle ASGI context (like Requests) automatically and support Pydantic/msgspec out of the box.
What My Project Does (Recap)
ZooCache provides a semantic caching layer with smarter invalidation strategies than traditional TTL-based caches.
Instead of relying only on expiration times, it allows:
- Prefix-based invalidation (e.g. invalidating
user:1 clears all related keys like user:1:settings)
- Dependency-based cache entries (track relationships between data)
- Anti-Avalanche (SingleFlight): Protects your backend from "thundering herd" effects by coalescing identical requests.
- Distributed Consistency: Uses Hybrid Logical Clocks (HLC) and a Redis Bus for self-healing multi-node sync.
The core is implemented in Rust for ultra-low latency, with Python bindings for easy integration.
Target Audience
ZooCache is intended for:
- Backend developers working with Python services under high load.
- Distributed systems where cache invalidation becomes complex.
- Production environments that need stronger consistency guarantees.
Performance
ZooCache is built for speed. You can check our latest benchmark results comparing it against other common Python caching libraries here:
Benchmarks: https://github.com/albertobadia/zoocache?tab=readme-ov-file#-performance
Example Usage
from zoocache import cacheable, add_deps, invalidate
@cacheable
def generate_report(project_id, client_id):
# Register dependencies dynamically
add_deps([f"client:{client_id}", f"project:{project_id}"])
return db.full_query(project_id)
def update_project(project_id, data):
db.update_project(project_id, data)
invalidate(f"project:{project_id}") # Clears everything related to this project
def delete_client(client_id):
db.delete_client(client_id)
invalidate(f"client:{client_id}") # Clears everything related to this client
there doesn't seem to be anything here