|
15 | 15 | - Unified builder API plus direct access for policy-specific operations. |
16 | 16 | - Optional metrics and benchmarks to validate trade-offs. |
17 | 17 |
|
| 18 | +## Table of Contents |
| 19 | +- [Overview](#overview) |
| 20 | +- [Main Features](#features) |
| 21 | +- [Feature Flags](#feature-flags) |
| 22 | +- [Installation](#installation) |
| 23 | +- [Quick Start](#quick-start) |
| 24 | +- [Available Policies](#available-policies) |
| 25 | +- [Policy Selection Guide](#policy-selection-guide) |
| 26 | +- [Direct Policy Access](#direct-policy-access) |
| 27 | +- [Documentation](https://oxidizelabs.github.io/cachekit/) |
| 28 | +- [Next Steps](#next-steps) |
| 29 | + |
| 30 | +## Overview |
| 31 | + |
| 32 | +CacheKit is a Rust library that provides: |
| 33 | + |
| 34 | +- High-performance cache replacement policies (e.g., **FIFO**, **LRU**, **LRU-K**, **Clock**, **NRU**, **S3-FIFO**, **SLRU**, **2Q**, and more). |
| 35 | +- Supporting data structures and policy primitives for building caches. |
| 36 | +- Optional metrics and benchmark harnesses. |
| 37 | +- A modular API suitable for embedding in systems where control over caching behavior is critical. |
| 38 | + |
| 39 | +This crate is designed for systems programming, microservices, and performance-critical applications. |
| 40 | + |
| 41 | +## Features |
| 42 | + |
| 43 | +- Policy implementations optimized for performance and predictability. |
| 44 | +- Optional integration with metrics collectors (e.g., Prometheus/metrics crates). |
| 45 | +- Benchmarks to compare policy performance under real-world workloads. |
| 46 | + |
18 | 47 | ## Installation |
19 | 48 |
|
20 | 49 | Add `cachekit` as a dependency in your `Cargo.toml`: |
21 | 50 |
|
22 | 51 | ```toml |
23 | 52 | [dependencies] |
24 | | -cachekit = "0.2.0" |
| 53 | +cachekit = "0.3.0" |
25 | 54 | ``` |
26 | 55 |
|
27 | | -From git (bleeding edge): |
| 56 | +From source: |
28 | 57 |
|
29 | 58 | ```toml |
30 | 59 | [dependencies] |
31 | 60 | cachekit = { git = "https://github.com/OxidizeLabs/cachekit" } |
32 | 61 | ``` |
33 | 62 |
|
| 63 | +## Quick Start |
| 64 | + |
| 65 | +### Using the Builder (Recommended) |
| 66 | + |
| 67 | +The `CacheBuilder` provides a unified API for creating caches with any eviction policy: |
| 68 | + |
| 69 | +```rust |
| 70 | +use cachekit::builder::{CacheBuilder, CachePolicy}; |
| 71 | + |
| 72 | +fn main() { |
| 73 | + // Create an LRU cache with a capacity of 100 entries |
| 74 | + let mut cache = CacheBuilder::new(100).build::<u64, String>(CachePolicy::Lru); |
| 75 | + |
| 76 | + // Insert items |
| 77 | + cache.insert(1, "value1".to_string()); |
| 78 | + cache.insert(2, "value2".to_string()); |
| 79 | + |
| 80 | + // Retrieve an item |
| 81 | + if let Some(value) = cache.get(&1) { |
| 82 | + println!("Got from cache: {}", value); |
| 83 | + } |
| 84 | + |
| 85 | + // Check existence and size |
| 86 | + assert!(cache.contains(&1)); |
| 87 | + assert_eq!(cache.len(), 2); |
| 88 | +} |
| 89 | +``` |
| 90 | + |
34 | 91 | ## Feature Flags |
35 | 92 |
|
36 | 93 | ### General |
@@ -71,51 +128,6 @@ Each eviction policy is gated behind a feature flag. Use `default-features = fal |
71 | 128 | cachekit = { version = "0.3", default-features = false, features = ["policy-lru", "policy-s3-fifo"] } |
72 | 129 | ``` |
73 | 130 |
|
74 | | -## Overview |
75 | | - |
76 | | -CacheKit is a Rust library that provides: |
77 | | - |
78 | | -- High-performance cache replacement policies (e.g., **FIFO**, **LRU**, **LRU-K**, **Clock**, **NRU**, **S3-FIFO**, **SLRU**, **2Q**, and more). |
79 | | -- Supporting data structures and policy primitives for building caches. |
80 | | -- Optional metrics and benchmark harnesses. |
81 | | -- A modular API suitable for embedding in systems where control over caching behavior is critical. |
82 | | - |
83 | | -This crate is designed for systems programming, microservices, and performance-critical applications. |
84 | | - |
85 | | -## Features |
86 | | - |
87 | | -- Policy implementations optimized for performance and predictability. |
88 | | -- Optional integration with metrics collectors (e.g., Prometheus/metrics crates). |
89 | | -- Benchmarks to compare policy performance under real-world workloads. |
90 | | - |
91 | | -## Quick Start |
92 | | - |
93 | | -### Using the Builder (Recommended) |
94 | | - |
95 | | -The `CacheBuilder` provides a unified API for creating caches with any eviction policy: |
96 | | - |
97 | | -```rust |
98 | | -use cachekit::builder::{CacheBuilder, CachePolicy}; |
99 | | - |
100 | | -fn main() { |
101 | | - // Create an LRU cache with a capacity of 100 entries |
102 | | - let mut cache = CacheBuilder::new(100).build::<u64, String>(CachePolicy::Lru); |
103 | | - |
104 | | - // Insert items |
105 | | - cache.insert(1, "value1".to_string()); |
106 | | - cache.insert(2, "value2".to_string()); |
107 | | - |
108 | | - // Retrieve an item |
109 | | - if let Some(value) = cache.get(&1) { |
110 | | - println!("Got from cache: {}", value); |
111 | | - } |
112 | | - |
113 | | - // Check existence and size |
114 | | - assert!(cache.contains(&1)); |
115 | | - assert_eq!(cache.len(), 2); |
116 | | -} |
117 | | -``` |
118 | | - |
119 | 131 | ### Available Policies |
120 | 132 |
|
121 | 133 | All policies are available through the unified builder API. Enable the corresponding feature flag for each policy (e.g. `policy-lru` for `CachePolicy::Lru`). See [Feature Flags](#per-policy-eviction-policies) above. |
@@ -227,4 +239,6 @@ fn main() { |
227 | 239 | - [Quickstart](docs/getting-started/quickstart.md) |
228 | 240 | - [Integration guide](docs/getting-started/integration.md) |
229 | 241 | - [Policy overview](docs/policies/README.md) |
| 242 | +- [Roadmap](docs/policies/roadmap/README.md) |
| 243 | +- [Testing](docs/testing/testing.md) |
230 | 244 | - [Benchmarks](docs/benchmarks/overview.md) |
0 commit comments