Expand description
skp-cache: Advanced, modular caching library for Rust
§Features
- Multi-tier caching (L1 Memory + L2 Redis)
- Dependency graph-based invalidation
- Pluggable serialization (JSON, MessagePack, Bincode)
- Metrics integration
- Stampede protection
§Quick Start
use skp_cache::prelude::*;
#[tokio::main]
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let backend = MemoryBackend::new(MemoryConfig::default());
let cache = CacheManager::new(backend);
cache.set("key", &42i32, CacheOpts::new().ttl_secs(60)).await?;
match cache.get::<i32>("key").await? {
CacheResult::Hit(entry) => println!("Got: {}", entry.value),
CacheResult::Miss => println!("Cache miss"),
_ => {}
}
Ok(())
}Modules§
- prelude
- Prelude for convenient imports
Structs§
- Cache
Entry - A cached entry with full metadata
- Cache
Group - A logical grouping of cache entries with shared namespace and invalidation
- Cache
Manager - High-level cache manager with pluggable serialization and metrics
- Cache
Manager Config - Configuration for CacheManager
- Cache
Options - Configuration options for a cache entry
- Cache
Opts - Builder for CacheOptions with fluent API
- Cache
Stats - Statistics for cache operations
- Composite
Key - Composite key builder for complex keys
- Json
Serializer - JSON serializer (default)
- Memory
Backend - In-memory cache backend
- Memory
Config - Configuration for the memory backend
- Noop
Compressor - No-op compressor (disabled compression)
- Noop
Metrics - No-op metrics implementation (default)
- Read
Through Cache - A cache wrapper that automatically loads data on miss
Enums§
- Cache
Error - Main error type for all cache operations
- Cache
Operation - Cache operation for latency tracking
- Cache
Result - Result of a cache lookup operation
- Cache
Tier - Cache tier for metrics labeling
- Eviction
Reason - Reason for cache eviction
Traits§
- Cache
Backend - Core trait for all cache storage backends
- Cache
Key - Trait for types that can be used as cache keys
- Cache
Manager Read Through Ext - Cache
Metrics - Trait for cache metrics/observability
- Compressor
- Trait for compression implementations
- Dependency
Backend - Extended trait for backends that support dependency tracking
- Distributed
Backend - Extended trait for distributed backends
- Loader
- Trait for automatic data loading on cache miss
- Serializer
- Trait for pluggable serialization formats
- Taggable
Backend - Extended trait for backends that support tag-based operations
Type Aliases§
- Result
- Result type alias for cache operations