Expand description
High-performance caching infrastructure for OxiMedia.
oximedia-cache provides sixteen complementary caching primitives:
lru_cache— arena-backed O(1) LRU cache with TTL expiration, entry pinning, hit/miss/eviction stats, and capacity resizetiered_cache— multi-tier (L1 memory → L2 memory → disk) cache with file-backed disk tier, adaptive promotion thresholds, entry compression for L2+ tiers, pluggable eviction (LRU/LFU/FIFO/Random/TinyLFU), and automatic promotion across tierscache_warming— predictive warming via access-pattern analysis, exponential inter-arrival EMA, auto-correlation periodicity detection, and score-ranked warmup plansbloom_filter— probabilistic membership filter (standard, counting with deletion, and scalable auto-growing variant) using FNV-1a double hashingdistributed_cache— consistent-hash ring with configurable virtual nodes, per-node client, quorum replication factor, and cluster coordinatoreviction_policies— standalone LFU tracker, frequency counter with decay, TinyLFU admission gate (optimized hot path), and ARC ghost-list trackercontent_aware_cache— media-type-aware cache with configurable weight factors per media type; scores eviction candidates by recency × priority × sizewrite_behind_cache— write-back cache with dirty tracking, flush-by-age, mark-clean, and backing-store abstractiontwo_queue— 2Q scan-resistant eviction policy (A1in FIFO + Am LRU- A1out ghost list) as alternative to LRU
cache_metrics— atomic hit/miss/eviction counters with latency percentile tracking andArc-shareable snapshotsprefetch— sequential media segment pre-loading based on access patterns with pluggable loader and pending queuesharded_lru— concurrent LRU cache sharded across N independentMutex<LruCache>instances to reduce lock contentioncache_partitioning— isolate cache space per tenant, stream, or workload with independent byte-level budgets and LRU evictioncache_serialization— persist the cache state to disk on shutdown and restore on startup using a zero-copy binary formatslab_allocator— fixed-size slab allocator for cache entries to reduce heap fragmentation in long-running processes
§Quick start
use oximedia_cache::lru_cache::LruCache;
let mut cache: LruCache<&str, Vec<u8>> = LruCache::new(128);
cache.insert("frame-001", vec![0u8; 4096], 4096);
assert!(cache.get(&"frame-001").is_some());Modules§
- bloom_
filter - Bloom filter for probabilistic cache membership testing.
- cache_
metrics - Cache metrics module: hit/miss rates, latency tracking, eviction counters.
- cache_
partitioning - Cache partitioning: isolate cache space per tenant, stream, or workload.
- cache_
serialization - Cache state serialization and restoration.
- cache_
warming - Predictive cache warming via access-pattern analysis.
- content_
aware_ cache - Media-content-aware caching.
- distributed_
cache - Distributed cache coordination primitives.
- eviction_
policies - Advanced eviction policy implementations.
- lru_
cache - High-performance LRU (Least Recently Used) cache with capacity management.
- prefetch
- Prefetch module: pre-loading sequential media segments based on access patterns.
- sharded_
lru - Sharded LRU cache for concurrent access with reduced lock contention.
- slab_
allocator - Slab allocator for cache entries.
- tiered_
cache - Multi-tier cache (L1 memory → L2 memory → disk).
- two_
queue - 2Q (two-queue) eviction policy — a scan-resistant alternative to LRU.
- write_
behind_ cache - Write-behind (write-back) cache with dirty tracking and flush.