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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Main cache type alias for the Quickleaf library.
//!
//! This module provides the main `Quickleaf` type, which is an alias for the `Cache` struct.
use crateCache;
/// Main cache type for the Quickleaf library.
///
/// `Quickleaf` is a type alias for `Cache`, providing the same functionality
/// with a more brand-focused name. Use this type when you want to emphasize
/// that you're using the Quickleaf caching library.
///
/// # Examples
///
/// ## Basic Usage
///
/// ```
/// use quickleaf::Quickleaf;
/// use quickleaf::valu3::traits::ToValueBehavior;
///
/// let mut cache = Quickleaf::new(100);
/// cache.insert("user_123", "session_data");
///
/// assert_eq!(cache.get("user_123"), Some(&"session_data".to_value()));
/// assert_eq!(cache.len(), 1);
/// ```
///
/// ## With TTL Support
///
/// ```
/// use quickleaf::Quickleaf;
/// use quickleaf::valu3::traits::ToValueBehavior;
/// use std::time::Duration;
///
/// let mut cache = Quickleaf::with_default_ttl(50, Duration::from_secs(300));
/// cache.insert("session", "active");
/// cache.insert_with_ttl("temp", "data", Duration::from_secs(60));
///
/// assert!(cache.contains_key("session"));
/// ```
///
/// ## With Event Notifications
///
/// ```
/// use quickleaf::{Quickleaf, Event};
/// use quickleaf::valu3::traits::ToValueBehavior;
/// use std::sync::mpsc::channel;
///
/// let (tx, rx) = channel();
/// let mut cache = Quickleaf::with_sender(10, tx);
///
/// cache.insert("monitor", "this");
///
/// // Receive the insert event
/// if let Ok(event) = rx.try_recv() {
/// match event {
/// Event::Insert(data) => {
/// assert_eq!(data.key, "monitor");
/// assert_eq!(data.value, "this".to_value());
/// },
/// _ => panic!("Expected insert event"),
/// }
/// }
/// ```
pub type Quickleaf = Cache;