2 releases
| 0.1.1 | Dec 30, 2025 |
|---|---|
| 0.1.0 | Dec 27, 2025 |
#265 in Caching
Used in armature-framework
125KB
2.5K
SLoC
armature-cache
Cache management for the Armature framework.
Features
- Multiple Backends - Redis, in-memory, and custom stores
- TTL Support - Automatic expiration
- Async API - Non-blocking cache operations
- Serialization - Automatic JSON serialization/deserialization
- Connection Pooling - Efficient Redis connections via bb8
Installation
[dependencies]
armature-cache = "0.1"
Quick Start
use armature_cache::{Cache, RedisCache};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to Redis
let cache = RedisCache::new("redis://localhost:6379").await?;
// Set a value with TTL
cache.set("key", "value", Some(Duration::from_secs(300))).await?;
// Get a value
let value: Option<String> = cache.get("key").await?;
// Delete a value
cache.delete("key").await?;
Ok(())
}
Backends
Redis
let cache = RedisCache::new("redis://localhost:6379").await?;
In-Memory
let cache = MemoryCache::new();
License
MIT OR Apache-2.0
Dependencies
~9–24MB
~278K SLoC