Skip to content

Commit 8ab374c

Browse files
authored
Enhance README with structured content and quick start guide (#18)
- Added a comprehensive Table of Contents for easier navigation. - Expanded the Overview section to clearly describe the library's purpose and features. - Included a Quick Start section with a code example demonstrating the use of the `CacheBuilder` for creating an LRU cache. - Updated the installation instructions to reflect the new version `0.3.0` and clarified the source installation method. - Removed redundant sections to streamline the documentation and improve clarity.
1 parent 53150da commit 8ab374c

1 file changed

Lines changed: 61 additions & 47 deletions

File tree

README.md

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,79 @@
1515
- Unified builder API plus direct access for policy-specific operations.
1616
- Optional metrics and benchmarks to validate trade-offs.
1717

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+
1847
## Installation
1948

2049
Add `cachekit` as a dependency in your `Cargo.toml`:
2150

2251
```toml
2352
[dependencies]
24-
cachekit = "0.2.0"
53+
cachekit = "0.3.0"
2554
```
2655

27-
From git (bleeding edge):
56+
From source:
2857

2958
```toml
3059
[dependencies]
3160
cachekit = { git = "https://github.com/OxidizeLabs/cachekit" }
3261
```
3362

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+
3491
## Feature Flags
3592

3693
### General
@@ -71,51 +128,6 @@ Each eviction policy is gated behind a feature flag. Use `default-features = fal
71128
cachekit = { version = "0.3", default-features = false, features = ["policy-lru", "policy-s3-fifo"] }
72129
```
73130

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-
119131
### Available Policies
120132

121133
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() {
227239
- [Quickstart](docs/getting-started/quickstart.md)
228240
- [Integration guide](docs/getting-started/integration.md)
229241
- [Policy overview](docs/policies/README.md)
242+
- [Roadmap](docs/policies/roadmap/README.md)
243+
- [Testing](docs/testing/testing.md)
230244
- [Benchmarks](docs/benchmarks/overview.md)

0 commit comments

Comments
 (0)