Skip to main content

Crate cache_mod

Crate cache_mod 

Source
Expand description

§cache-mod

HIGH-PERFORMANCE IN-PROCESS CACHING

Multiple eviction policies (LRU, LFU, TinyLFU, TTL, size-bounded). Async-safe, lock-minimized internals. Typed key-value API. No external store dependency.

§Status

The public API surface is defined: the Cache trait, the CacheError error type, and three reference cache implementations — LruCache (Least-Recently-Used, 0.2.0), LfuCache (Least-Frequently-Used, 0.3.0), and TtlCache (Time-To-Live with lazy expiry, 0.4.0). TinyLFU and size-bounded eviction policies land in 0.5.0. The API is not yet frozen — pin exact versions until 1.0.

§Quick start

use cache_mod::{Cache, LruCache};

let cache: LruCache<&'static str, u32> = LruCache::new(64).expect("capacity > 0");

cache.insert("requests", 1);
cache.insert("errors", 0);

assert_eq!(cache.get(&"requests"), Some(1));
assert_eq!(cache.len(), 2);

§License

Dual-licensed under Apache-2.0 OR MIT.

Structs§

LfuCachestd
A bounded, thread-safe LFU cache.
LruCachestd
A bounded, thread-safe LRU cache.
TtlCachestd
A bounded, thread-safe cache with per-entry time-to-live.

Enums§

CacheError
Errors produced by cache-mod.

Constants§

VERSION
Crate version string, populated by Cargo at build time.

Traits§

Cache
The common read / write / evict contract every cache type in this crate implements.