Nicolas Cache Documentation

PyPI Version Documentation Status

Nicolas Cache is a powerful Python caching library with multi-backend support and advanced tagging capabilities. It provides a unified interface for different cache backends including in-memory, Redis, and Redis Sentinel with automatic failover.

Key Features

  • Multiple Backends: In-memory, Redis, and Redis Sentinel support

  • Tag-Based Management: Organize cache entries with tags for bulk operations

  • TTL Support: Time-to-live for automatic cache expiration (Redis backends)

  • Automatic Failover: Redis Sentinel backend for high availability

  • Type Safety: Full type hints for better IDE support

  • Simple API: Consistent interface across all backends

  • Extensible: Easy to add new cache backends

Quick Example

from nicolas.cache import Cache

# Create a cache instance
cache = Cache(backend="memory")

# Store data with tags
cache.set("user:1", {"name": "Alice", "email": "alice@example.com"},
          tags=["users", "active"])

# Retrieve data
user = cache.get("user:1")

# Get all entries with a specific tag
active_users = cache.get_by_tag("active")

# Delete entries by tag
cache.delete_by_tag("inactive")

Indices and tables