Module cache

Module cache 

Source
Expand description

Cache abstraction layer for WarpDrive

This module provides a common trait for cache backends, enabling pluggable cache implementations (Redis, in-memory LRU, etc.).

The design follows zero-cost abstraction principles:

  • Async-first with tokio
  • Binary-safe (Vec) to support any serialization format
  • Generic error handling with anyhow
  • Minimal allocations in hot paths

§Example

use warpdrive::cache::{Cache, redis::RedisCache};

let cache = RedisCache::from_url(
    "redis://localhost:6379",
    "warpdrive:cache:".to_string()
).await?;

// Store data with 60 second TTL
cache.set("user:123", b"user_data", 60).await?;

// Retrieve data
if let Some(data) = cache.get("user:123").await? {
    println!("Found {} bytes", data.len());
}

Modules§

coordinator
Cache coordinator with distributed + local fallback strategy
invalidation
Cache invalidation via PostgreSQL LISTEN/NOTIFY
memory
In-memory LRU cache implementation
redis
Redis-based distributed cache implementation

Traits§

Cache
Common cache trait for all backend implementations