ax-cache
Concurrent in-memory cache for Rust with admission-controlled eviction.
- Sharded architecture
- S3-FIFO eviction
- TinyLFU admission filtering
- AES-accelerated hashing via
axhash - TTL support
- Thread-safe design
Installation
[]
= "0.1"
AES support is detected automatically at runtime.
Quick Start
use Cache;
let cache: = new;
cache.insert;
assert_eq!;
Construction
use Cache;
// Auto shard count
let cache = new;
// Explicit shard count
let cache = with_shards;
TTL Support
use Cache;
use Duration;
let cache = new;
cache.insert_with_ttl;
Expired entries are reclaimed lazily on access.
Shared Across Threads
use Cache;
use Arc;
use thread;
let cache = new;
let handles: = .map.collect;
for h in handles
Metrics
use Cache;
let cache = new;
let metrics = cache.metrics;
println!;
println!;
println!;
InsertOutcome
use ;
let cache = new;
match cache.insert
Maintenance Thread
use ;
use Duration;
let cache = new;
cache.enable_maintenance;
Background maintenance stops automatically when the cache is dropped.
Notes
capacityis approximate, not strict.- Operations are synchronous.
get()clones values. UseArc<T>for large payloads.- In-memory only. No persistence or serialization.
Links
- Crate: https://crates.io/crates/ax-cache
- Docs: https://docs.rs/ax-cache
- hashbrown: https://crates.io/crates/hashbrown
- parking_lot: https://crates.io/crates/parking_lot
- axhash: https://crates.io/crates/axhash-core
License
MIT