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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Cache Backend Implementations
//!
//! This module contains all cache backend implementations for the multi-tier cache system.
//!
//! # Available Backends
//!
//! ## In-Memory (L1 Tier)
//! - **Moka** - High-performance concurrent cache with automatic eviction (default L1)
//! - **`DashMap`** - Simple concurrent HashMap-based cache
//! - **`QuickCache`** - Lightweight, optimized for maximum performance (feature: `backend-quickcache`)
//!
//! ## Distributed (L2 Tier)
//! - **Redis** - Industry-standard distributed cache with persistence (default L2)
//! - **Memcached** - Lightweight distributed cache (feature: `backend-memcached`)
//!
//! ## On-Disk (L3/L4 Tier)
//! - **`RocksDB`** - Embedded persistent key-value store (coming soon)
//!
//! # Usage
//!
//! ```rust,no_run
//! use multi_tier_cache::backends::{MokaCache, MokaCacheConfig, RedisCache};
//!
//! # async fn example() -> anyhow::Result<()> {
//! // Explicit backend selection
//! let moka = MokaCache::new(MokaCacheConfig::default())?;
//! let redis = RedisCache::new().await?;
//!
//! // Or use type aliases for backward compatibility
//! use multi_tier_cache::backends::{L1Cache, L2Cache};
//! let l1 = L1Cache::new(MokaCacheConfig::default())?; // MokaCache
//! let l2 = L2Cache::new().await?; // RedisCache
//! # Ok(())
//! # }
//! ```
// Core backends (now optional via features)
// Core backends
// Optional backends (feature-gated)
// Re-export backend types
pub use DashMapCache;
pub use ;
pub use RedisCache;
pub use MemcachedCache;
pub use QuickCacheBackend;
// Type aliases for backward compatibility
// These allow existing code to continue working without changes
/// Type alias for `MokaCache` (default L1 backend)
pub type L1Cache = MokaCache;
/// Type alias for `RedisCache` (default L2 backend)
pub type L2Cache = RedisCache;
// Future backends will be added here with conditional compilation
// based on feature flags:
// #[cfg(feature = "backend-quickcache")]
// pub mod quickcache_cache;
// #[cfg(feature = "backend-quickcache")]
// pub use quickcache_cache::QuickCacheBackend;
// #[cfg(feature = "backend-dashmap")]
// pub mod dashmap_cache;
// #[cfg(feature = "backend-dashmap")]
// pub use dashmap_cache::DashMapCache;
// #[cfg(feature = "backend-rocksdb")]
// pub mod rocksdb_cache;
// #[cfg(feature = "backend-rocksdb")]
// pub use rocksdb_cache::RocksDBCache;