Skip to main content

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//! Foundation milestone (0.2.0). The public API surface is defined: the
11//! [`Cache`] trait, the [`LruCache`] reference implementation, and the
12//! [`CacheError`] error type. LFU, TinyLFU, TTL, and size-bounded eviction
13//! policies land in subsequent minors. The API is not yet frozen — pin
14//! 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 lru;
56
57pub use cache::Cache;
58pub use error::CacheError;
59
60#[cfg(feature = "std")]
61pub use lru::LruCache;
62
63/// Crate version string, populated by Cargo at build time.
64pub const VERSION: &str = env!("CARGO_PKG_VERSION");