cleep is a Clocksweep Cache implementation in Rust
Use it to keep your hot juicy records in memory for fast access.
Usage
Single Threaded example
use ClockCache;
let mut cache = new;
let v = cache.get;
Thread safe example
use Arc;
use thread;
use ConcurrentClockCache;
const SHARD_CAP: usize = 64;
const SHARDS: usize = 16;
let cache = new;
let mut handles = vec!;
let n_threads = available_parallelism.unwrap.get;
for t in 0..n_threads
for handle in handles
Limitations
The cache capacity in single-threaded implementation and the shard size and shard capacity in the concurrent version must be a power of two. This is so that we can avoid branching and modulo operations as much as possible on the hot paths and rely on bitwise operations.
License
This project is dual-licensed under the MIT and Apache-2.0 licenses. You can choose either license for your use.