cache_mod/lib.rs
1//! # cache-mod
2//!
3//! HIGH-PERFORMANCE IN-PROCESS CACHING
4//!
5//! Multiple eviction policies (LRU, LFU, TinyLFU, TTL, size-bounded). Async-safe,
6//! lock-minimized internals. Typed key-value API. No external store dependency.
7//!
8//! # Status
9//!
10//! The public API surface is defined: the [`Cache`] trait, the [`CacheError`]
11//! error type, and two reference cache implementations — [`LruCache`]
12//! (Least-Recently-Used, 0.2.0) and [`LfuCache`] (Least-Frequently-Used,
13//! 0.3.0). TinyLFU, TTL, and size-bounded eviction policies land in
14//! subsequent minors. The API is not yet frozen — pin exact versions until 1.0.
15//!
16//! # Quick start
17//!
18//! ```
19//! use cache_mod::{Cache, LruCache};
20//!
21//! let cache: LruCache<&'static str, u32> = LruCache::new(64).expect("capacity > 0");
22//!
23//! cache.insert("requests", 1);
24//! cache.insert("errors", 0);
25//!
26//! assert_eq!(cache.get(&"requests"), Some(1));
27//! assert_eq!(cache.len(), 2);
28//! ```
29//!
30//! # License
31//!
32//! Dual-licensed under Apache-2.0 OR MIT.
33
34#![doc(html_root_url = "https://docs.rs/cache-mod")]
35#![cfg_attr(docsrs, feature(doc_cfg))]
36#![cfg_attr(not(feature = "std"), no_std)]
37#![deny(missing_docs)]
38#![deny(unsafe_op_in_unsafe_fn)]
39#![deny(unused_must_use)]
40#![deny(unused_results)]
41#![deny(clippy::unwrap_used)]
42#![deny(clippy::expect_used)]
43#![deny(clippy::todo)]
44#![deny(clippy::unimplemented)]
45#![deny(clippy::print_stdout)]
46#![deny(clippy::print_stderr)]
47#![deny(clippy::dbg_macro)]
48#![deny(clippy::undocumented_unsafe_blocks)]
49#![deny(clippy::missing_safety_doc)]
50
51mod cache;
52mod error;
53
54#[cfg(feature = "std")]
55mod lfu;
56#[cfg(feature = "std")]
57mod lru;
58
59pub use cache::Cache;
60pub use error::CacheError;
61
62#[cfg(feature = "std")]
63pub use lfu::LfuCache;
64#[cfg(feature = "std")]
65pub use lru::LruCache;
66
67/// Crate version string, populated by Cargo at build time.
68pub const VERSION: &str = env!("CARGO_PKG_VERSION");