Skip to content

Repository files navigation

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.

See handoff for a reference thread architecture pairing direct reads with delegated writes. cache-rs owns no threads — that page describes the server side, and why the engine's publish protocol is already enough to make it correct.

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

About

A collection of Rust implementation of state-of-the-art cache algorithms

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages