@@ -42,7 +42,7 @@ cachekit = { git = "https://github.com/OxidizeLabs/cachekit" }
4242
4343CacheKit is a Rust library that provides:
4444
45- - High-performance cache replacement policies (e.g., ** FIFO** , ** LRU** , ** LRU-K** ).
45+ - High-performance cache replacement policies (e.g., ** FIFO** , ** LRU** , ** LRU-K** , ** S3-FIFO ** , ** SLRU ** , ** 2Q ** , and more ).
4646- Supporting data structures and policy primitives for building caches.
4747- Optional metrics and benchmark harnesses.
4848- A modular API suitable for embedding in systems where control over caching behavior is critical.
@@ -85,6 +85,8 @@ fn main() {
8585
8686### Available Policies
8787
88+ #### Builder API Policies
89+
8890``` rust
8991use cachekit :: builder :: {CacheBuilder , CachePolicy };
9092
@@ -116,17 +118,49 @@ let s3_fifo = CacheBuilder::new(100).build::<u64, String>(
116118);
117119```
118120
121+ #### Additional Policies (Direct Access)
122+
123+ These policies are available through direct instantiation but not yet exposed in the builder API:
124+
125+ ``` rust
126+ use cachekit :: policy :: lifo :: LifoCore ;
127+ use cachekit :: policy :: mfu :: MfuCore ;
128+ use cachekit :: policy :: mru :: MruCore ;
129+ use cachekit :: policy :: random :: RandomCore ;
130+ use cachekit :: policy :: slru :: SlruCore ;
131+
132+ // LIFO - Last In, First Out (stack-like eviction)
133+ let mut lifo : LifoCore <u64 , String > = LifoCore :: new (100 );
134+
135+ // MFU - Most Frequently Used (evicts hot items)
136+ let mut mfu : MfuCore <u64 , String > = MfuCore :: with_bucket_hint (100 , 32 );
137+
138+ // MRU - Most Recently Used (evicts recently accessed)
139+ let mut mru : MruCore <u64 , String > = MruCore :: new (100 );
140+
141+ // Random - Uniform random eviction
142+ let mut random : RandomCore <u64 , String > = RandomCore :: new (100 );
143+
144+ // SLRU - Segmented LRU with probationary/protected segments
145+ let mut slru : SlruCore <u64 , String > = SlruCore :: new (100 , 0.25 );
146+ ```
147+
119148### Policy Selection Guide
120149
121- | Policy | Best For | Eviction Basis |
122- | ---------| ----------| ----------------|
123- | FIFO | Simple, predictable workloads | Insertion order |
124- | LRU | Temporal locality | Recency |
125- | LRU-K | Scan-resistant workloads | K-th access time |
126- | LFU | Stable access patterns | Frequency (O(1)) |
127- | HeapLFU | Large caches, frequent evictions | Frequency (O(log n)) |
128- | 2Q | Mixed workloads | Two-queue promotion |
129- | S3-FIFO | Scan-heavy workloads | FIFO + ghost history |
150+ | Policy | Best For | Eviction Basis | Builder API |
151+ | ---------| ----------| ----------------| -------------|
152+ | FIFO | Simple, predictable workloads | Insertion order | ✓ |
153+ | LRU | Temporal locality | Recency | ✓ |
154+ | LRU-K | Scan-resistant workloads | K-th access time | ✓ |
155+ | LFU | Stable access patterns | Frequency (O(1)) | ✓ |
156+ | HeapLFU | Large caches, frequent evictions | Frequency (O(log n)) | ✓ |
157+ | 2Q | Mixed workloads | Two-queue promotion | ✓ |
158+ | S3-FIFO | Scan-heavy workloads | FIFO + ghost history | ✓ |
159+ | LIFO | Stack-like caching | Reverse insertion order | - |
160+ | MFU | Inverse frequency | Highest frequency | - |
161+ | MRU | Anti-recency patterns | Most recent access | - |
162+ | Random | Baseline/uniform distribution | Random selection | - |
163+ | SLRU | Scan resistance | Segmented LRU | - |
130164
131165See [ Choosing a policy] ( docs/guides/choosing-a-policy.md ) for benchmark-driven guidance.
132166
0 commit comments