Expand description
§elif-cache
A comprehensive multi-backend caching system for the elif.rs framework.
§Features
- Multi-backend support: Memory, Redis, and file-based caching
- Cache tagging: Group related cache entries for batch invalidation
- TTL support: Time-based cache expiration
- Async-first: Built for modern async Rust applications
- Type-safe: Generic cache operations with serialization support
- HTTP integration: Response caching utilities for web applications
§Quick Start
use elif_cache::{Cache, MemoryBackend, CacheConfig};
use std::time::Duration;
// Create a memory-based cache
let cache = Cache::new(MemoryBackend::new(CacheConfig::default()));
// Store a value
cache.put("user:123", &"John Doe".to_string(), Duration::from_secs(3600)).await.unwrap();
// Retrieve a value
let user: Option<String> = cache.get("user:123").await.unwrap();
assert_eq!(user, Some("John Doe".to_string()));
// Use the remember pattern
let expensive_data = cache.remember(
"expensive:computation",
Duration::from_secs(3600),
|| async { "computed value".to_string() }
).await.unwrap();Re-exports§
pub use backends::*;pub use config::*;pub use tagging::*;pub use invalidation::*;pub use warming::*;
Modules§
- backends
- Cache backend implementations
- config
- Cache configuration and builder
- invalidation
- Cache invalidation strategies
- tagging
- Cache tagging and invalidation system
- warming
- Cache warming and preloading system
Structs§
- Cache
- High-level cache interface with type-safe operations
- Cache
Stats - Cache statistics
Enums§
- Cache
Error - Cache operation errors
Traits§
- Cache
Backend - Core cache backend trait that all cache implementations must implement
Functions§
- global_
cache - Get the global cache instance
- set_
global_ cache - Set the global cache instance
Type Aliases§
- Cache
Key - Cache key type
- Cache
Result - Result type for cache operations
- Cache
Tag - Cache tags for grouping related entries