Expand description
Caches
This is a Rust implementation for popular caches (support no_std).
See Introduction, Installation and Usages for more details.
Introduction
The MSRV for this crate is 1.55.0.
- LRU
LRUCache
,SegmentedCache
,TwoQueueCache
andAdaptiveCache
.- LFU
TinyLFU
,SampledLFU
, andWTinyLFUCache
Installation
- std
[dependencies]
caches = "0.2"
- no_std
[dependencies]
caches = { version: "0.2", default-features = false }
Usages
Please see examples
.
Roadmap
-
0.2
: Support TinyLFU, SampledLFU, WTinyLFUCache -
0.3
: Support LIRS, DLIRS, DSLRU -
0.4
: Add ttl feature to support
Related
If you want a high-performance thread-safe modern cache, please see stretto
Acknowledgments
-
The implementation of
RawLRU
is highly inspired by Jerome Froelich’s LRU implementation andstd::collections
library of Rust. -
Thanks for HashiCorp’s golang-lru providing the amazing Go implementation.
-
Ramakrishna’s paper: Caching strategies to improve disk system performance
-
The implementation of TinyLFU and SampledLFU are inspired by Dgraph’s ristretto and dgryski’s go-tinylfu.
-
Gil Einziger’s paper: TinyLFU: A Highly Efficient Cache Admission Policy
Re-exports
pub use lru::AdaptiveCache;
pub use lru::AdaptiveCacheBuilder;
pub use lru::LRUCache;
pub use lru::RawLRU;
pub use lru::SegmentedCache;
pub use lru::SegmentedCacheBuilder;
pub use lru::TwoQueueCache;
pub use lru::TwoQueueCacheBuilder;
pub use lfu::WTinyLFUCache;
pub use lfu::WTinyLFUCacheBuilder;
Modules
- LFU based caches implementation.
- LRU based caches implementation.
Structs
DefaultEvictCallback
is a noop evict callback.
Enums
PutResult
is returned when try to put a entry in cache.
Traits
- Cache contains the basic APIs for a cache. All of caches in this crate implement this trait.
OnEvictCallback
is used to apply a callback for evicted entry.- Implement this trait for Cache to support resize.
Type Aliases
- Re-export for DefaultHashBuilder