1#[cfg(all(feature = "cache_request", feature = "cache", not(feature = "cache_mem")))]
4use http_cache_reqwest::CACacheManager;
5
6#[cfg(all(feature = "cache_request", feature = "cache", not(feature = "cache_mem")))]
7type RequestCacheManager = CACacheManager;
8
9#[cfg(all(feature = "cache_request", feature = "cache_mem", not(feature = "cache")))]
12use http_cache_reqwest::MokaManager;
13
14#[cfg(all(feature = "cache_request", feature = "cache_mem", not(feature = "cache")))]
15type RequestCacheManager = MokaManager;
16
17#[cfg(all(feature = "cache_request", feature = "cache", feature = "cache_mem"))]
22use http_cache_reqwest::MokaManager;
23
24#[cfg(all(feature = "cache_request", feature = "cache", feature = "cache_mem"))]
25type RequestCacheManager = MokaManager;
26
27#[cfg(all(feature = "cache_request", not(feature = "cache"), not(feature = "cache_mem")))]
30use http_cache_reqwest::CACacheManager;
31
32#[cfg(all(feature = "cache_request", not(feature = "cache"), not(feature = "cache_mem")))]
33type RequestCacheManager = CACacheManager;
34
35#[cfg(feature = "cache_request")]
38lazy_static::lazy_static! {
39 pub static ref CACACHE_MANAGER: RequestCacheManager = RequestCacheManager::default();
41}
42
43#[cfg(test)]
44mod tests {
45 #[cfg(all(feature = "cache_request", feature = "cache", feature = "cache_mem"))]
46 #[test]
47 fn test_both_cache_features_prefer_memory_manager() {
48 fn manager_type_name<T>(_: &T) -> &'static str {
49 std::any::type_name::<T>()
50 }
51
52 let ty = manager_type_name(&*super::CACACHE_MANAGER);
53 assert!(
54 ty.contains("MokaManager"),
55 "expected MokaManager when both cache and cache_mem are enabled, got {ty}"
56 );
57 }
58}