pub trait CacheBackend: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn get(&self, key: &str) -> Result<Option<CacheEntry>, String>;
fn set(
&self,
key: &str,
entry: CacheEntry,
ttl_ms: Option<u64>,
) -> Result<(), String>;
fn delete(&self, key: &str) -> Result<bool, String>;
fn invalidate_tag(&self, tag: &str) -> Result<u32, String>;
fn invalidate_path(&self, pattern: &str) -> Result<u32, String>;
// Provided method
fn is_healthy(&self) -> bool { ... }
}Expand description
Alternative cache storage backend (e.g., Redis, S3, Cloudflare KV).
Replaces or wraps the built-in LRU cache for ISR entries. Only one backend can be active at a time.
Required Methods§
Sourcefn get(&self, key: &str) -> Result<Option<CacheEntry>, String>
fn get(&self, key: &str) -> Result<Option<CacheEntry>, String>
Look up a cached entry. Returns Ok(None) on miss.
Sourcefn set(
&self,
key: &str,
entry: CacheEntry,
ttl_ms: Option<u64>,
) -> Result<(), String>
fn set( &self, key: &str, entry: CacheEntry, ttl_ms: Option<u64>, ) -> Result<(), String>
Store an entry with optional TTL in milliseconds.
Sourcefn delete(&self, key: &str) -> Result<bool, String>
fn delete(&self, key: &str) -> Result<bool, String>
Delete a single entry by key. Returns whether it existed.
Provided Methods§
Sourcefn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
Health check. Default returns true.