Expand description
Cache module for Kit framework
Provides a Redis-backed cache with automatic in-memory fallback.
§Quick Start
The cache is automatically initialized when the server starts. If Redis is
available (via REDIS_URL), it uses Redis. Otherwise, it falls back to
an in-memory cache.
ⓘ
use kit::Cache;
use std::time::Duration;
// Store a value with 1 hour TTL
Cache::put("user:1", &user, Some(Duration::from_secs(3600))).await?;
// Retrieve it
let cached: Option<User> = Cache::get("user:1").await?;
// Check if exists
if Cache::has("user:1").await? {
// ...
}
// Remove it
Cache::forget("user:1").await?;
// Clear all cache
Cache::flush().await?;Re-exports§
pub use config::CacheConfig;pub use config::CacheConfigBuilder;pub use memory::InMemoryCache;pub use redis::RedisCache;pub use store::CacheStore;
Modules§
- config
- Cache configuration for Kit framework
- memory
- In-memory cache implementation for testing and fallback
- redis
- Redis-backed cache implementation
- store
- Cache store trait definition
Structs§
- Cache
- Cache facade - main entry point for cache operations