1#![warn(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
9#![warn(missing_docs)]
10
11#[cfg(all(feature = "workers", feature = "redis"))]
13compile_error!(
14 "features `workers` and `redis` are mutually exclusive — Workers runtime cannot use fred"
15);
16
17#[cfg(all(feature = "workers", feature = "l1"))]
18compile_error!("features `workers` and `l1` are mutually exclusive — moka requires std threads unavailable in wasm32");
19
20#[cfg(all(feature = "workers", feature = "reliability"))]
21compile_error!("features `workers` and `reliability` are mutually exclusive — retry/breaker timers need tokio `time`, unavailable in wasm32");
22
23#[cfg(all(feature = "workers", feature = "memcached"))]
24compile_error!("features `workers` and `memcached` are mutually exclusive — Workers runtime has no TCP sockets");
25
26#[cfg(all(feature = "workers", feature = "file"))]
27compile_error!(
28 "features `workers` and `file` are mutually exclusive — Workers runtime has no filesystem"
29);
30
31pub mod backend;
34pub mod client;
36pub mod config;
38pub mod error;
40pub mod flight;
42pub mod interop;
44pub mod metrics;
46pub mod serializer;
48pub mod session;
50pub mod url_validator;
52
53mod intents;
55
56#[cfg(feature = "encryption")]
58pub mod encryption;
59
60#[cfg(feature = "l1")]
62pub mod l1;
63
64#[cfg(all(feature = "reliability", not(target_arch = "wasm32")))]
66pub mod reliability;
67
68pub use client::{CacheKit, CacheKitBuilder, SharedBackend, SwrRead, SwrToken};
70pub use config::CachekitConfig;
71pub use error::{BackendError, BackendErrorKind, CachekitError};
72
73#[cfg(feature = "encryption")]
74pub use client::SecureCache;
75#[cfg(feature = "encryption")]
76pub use encryption::EncryptionLayer;
77
78#[cfg(feature = "macros")]
79pub use cachekit_macros::cachekit;
80
81pub use flight::SingleFlight;
82
83#[cfg(all(feature = "reliability", not(target_arch = "wasm32")))]
84pub use reliability::{BackpressureConfig, CircuitBreakerConfig, ReliabilityConfig, RetryConfig};
85
86#[cfg(any(
93 feature = "l1",
94 all(feature = "reliability", not(target_arch = "wasm32"))
95))]
96pub(crate) fn random_unit() -> f64 {
97 let bits = uuid::Uuid::new_v4().as_u128() & ((1u128 << 53) - 1);
98 (bits as f64) / ((1u64 << 53) as f64)
99}
100
101#[cfg(all(feature = "l1", not(feature = "unsync"), not(target_arch = "wasm32")))]
111#[doc(hidden)]
112pub fn __swr_spawn<F>(fut: F)
113where
114 F: std::future::Future<Output = ()> + Send + 'static,
115{
116 if let Ok(handle) = tokio::runtime::Handle::try_current() {
117 drop(handle.spawn(fut));
118 }
119}
120
121#[cfg(not(all(feature = "l1", not(feature = "unsync"), not(target_arch = "wasm32"))))]
126#[doc(hidden)]
127pub fn __swr_spawn<F>(_fut: F)
128where
129 F: std::future::Future<Output = ()> + 'static,
130{
131}
132
133pub mod prelude {
135 pub use crate::{
136 BackendError, BackendErrorKind, CacheKit, CacheKitBuilder, CachekitConfig, CachekitError,
137 SwrRead, SwrToken,
138 };
139
140 #[cfg(feature = "encryption")]
141 pub use crate::{EncryptionLayer, SecureCache};
142
143 #[cfg(feature = "macros")]
144 pub use crate::cachekit;
145}