micro_moka/lib.rs
1#![warn(clippy::all)]
2#![warn(rust_2018_idioms)]
3#![deny(rustdoc::broken_intra_doc_links)]
4#![cfg_attr(docsrs, feature(doc_cfg))]
5
6//! Micro Moka is a lightweight cache library for Rust. Micro Moka is a fork
7//! of [Mini Moka][mini-moka-git], stripped down to the bare essentials.
8//!
9//! Micro Moka provides an in-memory, non-thread-safe cache implementation for
10//! single thread applications.
11//!
12//! All cache implementations perform a best-effort bounding of the map using an
13//! entry replacement algorithm to determine which entries to evict when the capacity
14//! is exceeded.
15//!
16//! [moka-git]: https://github.com/moka-rs/moka
17//! [mini-moka-git]: https://github.com/moka-rs/mini-moka
18//! [caffeine-git]: https://github.com/ben-manes/caffeine
19//!
20//! # Features
21//!
22//! - A cache can be bounded by the maximum number of entries.
23//! - Maintains good hit rate by using entry replacement algorithms inspired by
24//! [Caffeine][caffeine-git]:
25//! - Admission to a cache is controlled by the Least Frequently Used (LFU) policy.
26//! - Eviction from a cache is controlled by the Least Recently Used (LRU) policy.
27//!
28//! # Examples
29//!
30//! See the following document:
31//!
32//! - A not thread-safe, blocking cache for single threaded applications:
33//! - [`unsync::Cache`][unsync-cache-struct]
34//!
35//! [unsync-cache-struct]: ./unsync/struct.Cache.html
36//!
37//! # Minimum Supported Rust Versions
38//!
39//! This crate's minimum supported Rust versions (MSRV) are the followings:
40//!
41//! | Feature | MSRV |
42//! |:-----------------|:--------------------------:|
43//! | default features | Rust 1.76.0 (Feb 8, 2024) |
44//!
45//! If only the default features are enabled, MSRV will be updated conservatively.
46//! When using other features, MSRV might be updated more frequently, up to the
47//! latest stable. In both cases, increasing MSRV is _not_ considered a
48//! semver-breaking change.
49
50pub(crate) mod common;
51pub(crate) mod policy;
52pub mod unsync;
53
54pub use policy::Policy;
55
56#[cfg(all(doctest))]
57mod doctests {
58 // https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#include-items-only-when-collecting-doctests
59 #[doc = include_str!("../README.md")]
60 struct ReadMeDoctests;
61}