1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! A high-performance LRU (Least Recently Used) cache implementation in Rust.
//!
//! This crate provides two LRU cache implementations:
//!
//! 1. [`BasicLruCache`] - A thread-safe LRU cache implementation using fine-grained locking
//! 2. [`ShardedLruCache`] - A sharded LRU cache implementation for better concurrent performance
//!
//! # Features
//!
//! - Thread-safe implementations
//! - High-performance concurrent access
//! - Memory-efficient storage
//! - Configurable capacity
//! - Generic key type support
//! - Automatic sharding for better scalability
//!
//! # Examples
//!
//! ```rust
//! use lrust_cache::{BasicLruCache, ShardedLruCache};
//!
//! // Create a basic LRU cache for storing strings with string keys
//! let basic_cache: BasicLruCache<String, String> = BasicLruCache::new(1000);
//!
//! // Create a sharded LRU cache for better concurrent performance
//! let sharded_cache: ShardedLruCache<String, String> = ShardedLruCache::new(1000);
//!
//! // You can use any type that implements Clone + Debug + Hash + Eq + Send + Sync + 'static as key
//! let cache: BasicLruCache<u64, String> = BasicLruCache::new(1000);
//! cache.put(42, "answer".to_string());
//! assert_eq!(cache.get(&42), Some("answer".to_string()));
//! ```
pub use BasicLruCache;
pub use ShardedLruCache;