2 unstable releases
| 0.3.0 | Aug 19, 2025 |
|---|---|
| 0.2.0 | Aug 17, 2025 |
#313 in Caching
44 downloads per month
Used in 2 crates
(via elif-web)
1MB
19K
SLoC
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();
Dependencies
~12–25MB
~355K SLoC