Module coordinator

Module coordinator 

Source
Expand description

Cache coordinator with distributed + local fallback strategy

This module provides a high-level cache coordinator that manages both distributed (Redis) and local (Memory) caches with automatic fallback.

§Architecture

┌─────────────┐
│ Coordinator │
└──────┬──────┘
       │
   ┌───┴───┐
   │       │
   ▼       ▼
┌─────┐ ┌────────┐
│Redis│ │ Memory │
└─────┘ └────────┘
  (L2)     (L1)

Strategy:

  • GET: L1 → L2 → upstream (populate L1 + L2 on miss)
  • SET: L1 + L2 (write-through)
  • DELETE: L1 + L2 (invalidate both)

Fallback:

  • If Redis unavailable, use Memory only
  • If Redis operation fails, continue with Memory
  • Log degraded mode for monitoring

§Example

use warpdrive::cache::coordinator::CacheCoordinator;
use warpdrive::config::Config;

let config = Config::from_env()?;
let cache = CacheCoordinator::from_config(&config).await?;

// Use cache (automatic Redis → Memory fallback)
cache.set("key", b"value", 60).await?;
let value = cache.get("key").await?;

Structs§

CacheCoordinator
Cache coordinator managing distributed and local caches

Enums§

CacheBackend
Cache backend selection