You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add eviction policy feature flags for modular builds
- Introduced feature flags for various eviction policies in `Cargo.toml`, allowing users to enable only the necessary policies for smaller builds.
- Updated documentation to reflect the new feature flags and their descriptions, enhancing clarity on usage and configuration.
- Modified `bench-support/Cargo.toml` to utilize the `policy-all` feature for comprehensive benchmarking.
- Ensured that the new feature flags are integrated into the cache builder and prelude for seamless access to different policies.
* Update default feature flags in Cargo.toml for eviction policies
- Changed the default feature flags to include specific eviction policies: `policy-s3-fifo`, `policy_lru`, `policy-fast-lru`, `policy_lru_k`, and `policy-clock`.
- This update allows for more targeted usage of eviction strategies, enhancing modularity and performance based on expected workload patterns.
* Fix typo in default feature flags in Cargo.toml
- Corrected the naming convention of the `policy_lru` feature flag to `policy-lru` for consistency with other feature flags.
- This change enhances clarity and maintains uniformity in the feature flag naming scheme.
* Enhance documentation for eviction policy feature flags
- Updated README and various documentation files to clarify that each eviction policy is gated behind a feature flag, improving modularity for builds.
- Added feature flag details for each policy in the documentation, ensuring users can easily identify and enable the necessary policies for their use cases.
- Included examples for minimal builds and emphasized the benefits of targeted feature usage for performance optimization.
**Convenience:**`policy-all` enables every policy above.
68
+
69
+
```toml
70
+
# Minimal build: only LRU and S3-FIFO
71
+
cachekit = { version = "0.3", default-features = false, features = ["policy-lru", "policy-s3-fifo"] }
72
+
```
73
+
41
74
## Overview
42
75
43
76
CacheKit is a Rust library that provides:
@@ -85,7 +118,7 @@ fn main() {
85
118
86
119
### Available Policies
87
120
88
-
All policies are available through the unified builder API:
121
+
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.
Each policy requires its feature flag (e.g. `policy-lru` for `CachePolicy::Lru`). See [Compatibility and Features](../guides/compatibility-and-features.md).
67
+
68
+
| Policy | Feature | Use Case | Trade-offs |
69
+
|--------|---------|----------|------------|
70
+
|`Fifo`|`policy-fifo`| Simple, predictable eviction | No recency/frequency tracking |
71
+
|`Lru`|`policy-lru`| Temporal locality | Vulnerable to scans |
72
+
|`FastLru`|`policy-fast-lru`| Maximum single-threaded speed | No Arc wrapping, no concurrent wrapper |
73
+
|`LruK { k }`|`policy-lru-k`| Scan resistance | Extra memory for history |
74
+
|`Lfu { bucket_hint }`|`policy-lfu`| Stable hot spots | Slow to adapt to changes |
75
+
|`HeapLfu`|`policy-heap-lfu`| Large caches, frequent evictions | O(log n) eviction |
Copy file name to clipboardExpand all lines: docs/getting-started/quickstart.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,18 @@ Add CacheKit to your `Cargo.toml`:
8
8
9
9
```toml
10
10
[dependencies]
11
-
cachekit = "0.2.0-alpha"
11
+
cachekit = "0.3"
12
12
```
13
13
14
+
Each eviction policy is gated behind a feature flag. The default features include `policy-s3-fifo`, `policy-lru`, `policy-fast-lru`, `policy-lru-k`, and `policy-clock`. For minimal builds, use `default-features = false` and enable only the policies you need:
15
+
16
+
```toml
17
+
[dependencies]
18
+
cachekit = { version = "0.3", default-features = false, features = ["policy-lru"] }
19
+
```
20
+
21
+
See [Compatibility and Features](../guides/compatibility-and-features.md) for the full list of per-policy feature flags.
Copy file name to clipboardExpand all lines: docs/guides/api-surface.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,10 @@ This page maps the major modules and how they fit together.
17
17
3. Use the unified `Cache<K, V>` API for standard operations.
18
18
4. Drop into `policy::*` or `ds::*` for advanced or policy-specific operations.
19
19
20
+
## Feature Flags
21
+
22
+
Policies are gated behind feature flags (e.g. `policy-lru`, `policy-s3-fifo`). Use `default-features = false` and enable only the policies you need. See [Compatibility and Features](compatibility-and-features.md).
Copy file name to clipboardExpand all lines: docs/guides/choosing-a-policy.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@
3
3
This guide summarizes practical trade-offs and mirrors the benchmark-driven guidance
4
4
in the [latest benchmark guide](../benchmarks/latest/index.md).
5
5
6
+
**Feature flags:** Each policy is gated behind a feature flag (e.g. `policy-lru`, `policy-s3-fifo`). Enable only the policies you need for smaller builds. See [Compatibility and Features](compatibility-and-features.md).
7
+
6
8
## Quick Picks
7
9
8
10
-**General purpose, skewed workloads**: `LRU` or `S3-FIFO`
0 commit comments