Module cache

Module cache 

Source
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§

CacheConfig
Cache configuration
MemoryCache
In-memory cache with TTL support

Enums§

CacheError
Errors that can occur during cache operations

Traits§

Cache
A cache backend that can store and retrieve values
CacheExt
Extension trait for cache operations with typed keys
CacheKey
Cache key generation trait

Type Aliases§

CacheResult
Result type for cache operations that can fail