Bazuka
Bazuka is a high-performance, asynchronous, multi-value cache for Rust for tokio runtime. It allows you to associate multiple values with a single key, each with its own expiry, and is designed for concurrent use in async environments (e.g., with Tokio).
Features
- Multi-value per key: Store multiple values for each key.
- Per-value TTL: Each value can have its own time-to-live.
- Async and thread-safe: Built for use with Tokio and safe for concurrent access.
- Customizable expiry: Supports idle and timeout expiry for keys.
- Efficient memory usage: Backed by moka and dashmap for speed and safety.
Usage
use ;
use tokio;
async
API Overview
SkmvCache::new(config): Create a new cache with the given configuration.insert(key, value, ttl): Insert a value for a key with a specific TTL (seconds) or update a previously inserted pair's ttl.get(&key) -> Vec<Arc<V>>: Get all values for a key.remove(key, value): Remove a specific value for a key.
Configuration
Example: Per-value Expiry
cache.insert.await; // expires in 5s
cache.insert.await; // expires in 10s
// update ttl
cache.insert.await; // updated ttl of the specific value to 8 sec
Testing
The crate includes comprehensive async tests for insertion, retrieval, removal, concurrency, and expiry.
License
MIT
Bazuka: Fast, flexible, async multi-value cache for Rust.