3 unstable releases
| 0.2.0 | Apr 15, 2026 |
|---|---|
| 0.1.1 | Jan 3, 2024 |
| 0.1.0 | Dec 19, 2023 |
#108 in Caching
Used in cachesim-rs
230KB
4.5K
SLoC
cache-rs
Rust implementations of cache storage engines from Pelikan.
Crates
| Crate | Description |
|---|---|
| segcache | Segment-structured cache engine with pluggable eviction policies |
| cuckoo-cache | Array-based cuckoo hash cache with fixed-size item slots |
| keyvalue | Shared packed item types (Value, RawItem, TinyItem) |
| datatier | Byte storage pool abstraction (anonymous mmap, file-backed mmap, hybrid) |
See design for architecture details and eviction policy comparison.
Quick Start
use segcache::{Policy, Segcache};
use std::time::Duration;
const MB: usize = 1024 * 1024;
let mut cache = Segcache::builder()
.heap_size(64 * MB)
.segment_size(1 * MB as i32)
.hash_power(16)
.eviction(Policy::S3Fifo { admission_ratio: 0.10 })
.build()
.expect("failed to create cache");
cache.insert(b"key", b"value", None, Duration::from_secs(300))?;
let item = cache.get(b"key").expect("not found");
assert_eq!(item.value(), b"value");
cache.delete(b"key");
Building
cargo build --workspace
cargo test --workspace
License
MIT OR Apache-2.0
lib.rs:
This crate is a Rust implementation of the Segcache storage layer.
It is a high-throughput and memory-efficient key-value store with eager expiration. Segcache uses a segment-structured design that stores data in fixed-size segments, grouping objects with nearby expiration time into the same segment, and lifting most per-object metadata into the shared segment header. This reduces object metadata by 88% compared to Memcached.
A blog post about the overall design can be found here: https://pelikan.io/2021/segcache.html
Goals:
- high-throughput item storage
- eager expiration of items
- low metadata overhead
Non-goals:
- not designed for concurrent access
Dependencies
~2.2–3.5MB
~65K SLoC