1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! 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 resize
//! - [`tiered_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 tiers
//! - [`cache_warming`] — predictive warming via access-pattern analysis,
//! exponential inter-arrival EMA, auto-correlation periodicity detection, and
//! score-ranked warmup plans
//! - [`bloom_filter`] — probabilistic membership filter (standard, counting
//! with deletion, and scalable auto-growing variant) using FNV-1a double
//! hashing
//! - [`distributed_cache`] — consistent-hash ring with configurable virtual
//! nodes, per-node client, quorum replication factor, and cluster coordinator
//! - [`eviction_policies`] — standalone LFU tracker, frequency counter with
//! decay, TinyLFU admission gate (optimized hot path), and ARC ghost-list
//! tracker
//! - [`content_aware_cache`] — media-type-aware cache with configurable weight
//! factors per media type; scores eviction candidates by recency × priority ×
//! size
//! - [`write_behind_cache`] — write-back cache with dirty tracking,
//! flush-by-age, mark-clean, and backing-store abstraction
//! - [`two_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 and `Arc`-shareable snapshots
//! - [`prefetch`] — sequential media segment pre-loading based on access
//! patterns with pluggable loader and pending queue
//! - [`sharded_lru`] — concurrent LRU cache sharded across N independent
//! `Mutex<LruCache>` instances to reduce lock contention
//! - [`cache_partitioning`] — isolate cache space per tenant, stream, or
//! workload with independent byte-level budgets and LRU eviction
//! - [`cache_serialization`] — persist the cache state to disk on shutdown and
//! restore on startup using a zero-copy binary format
//! - [`slab_allocator`] — fixed-size slab allocator for cache entries to
//! reduce heap fragmentation in long-running processes
//!
//! # Quick start
//!
//! ```rust
//! 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());
//! ```