Expand description
Cache abstraction with in-memory and Redis backends.
Provides a unified caching interface with configurable TTL and eviction. Cache abstraction for AllFrame applications
This module provides a unified cache interface with support for multiple backends including in-memory caching and Redis.
§Example
ⓘ
use allframe_core::cache::{Cache, MemoryCache};
use std::time::Duration;
#[tokio::main]
async fn main() {
let cache = MemoryCache::new();
// Set a value with TTL
cache.set("key", &"value", Some(Duration::from_secs(60))).await;
// Get the value
let value: Option<String> = cache.get("key").await;
assert_eq!(value, Some("value".to_string()));
}Structs§
- Cache
Config - Cache configuration
- Memory
Cache - In-memory cache with TTL support
Enums§
- Cache
Error - Errors that can occur during cache operations
Traits§
- Cache
- A cache backend that can store and retrieve values
- Cache
Ext - Extension trait for cache operations with typed keys
- Cache
Key - Cache key generation trait
Type Aliases§
- Cache
Result - Result type for cache operations that can fail