#![warn(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
#![warn(missing_docs)]
#[cfg(all(feature = "workers", feature = "redis"))]
compile_error!(
"features `workers` and `redis` are mutually exclusive — Workers runtime cannot use fred"
);
#[cfg(all(feature = "workers", feature = "l1"))]
compile_error!("features `workers` and `l1` are mutually exclusive — moka requires std threads unavailable in wasm32");
#[cfg(all(feature = "workers", feature = "reliability"))]
compile_error!("features `workers` and `reliability` are mutually exclusive — retry/breaker timers need tokio `time`, unavailable in wasm32");
#[cfg(all(feature = "workers", feature = "memcached"))]
compile_error!("features `workers` and `memcached` are mutually exclusive — Workers runtime has no TCP sockets");
#[cfg(all(feature = "workers", feature = "file"))]
compile_error!(
"features `workers` and `file` are mutually exclusive — Workers runtime has no filesystem"
);
pub mod backend;
pub mod client;
pub mod config;
pub mod error;
pub mod flight;
pub mod interop;
pub mod metrics;
pub mod serializer;
pub mod session;
pub mod url_validator;
mod intents;
#[cfg(feature = "encryption")]
pub mod encryption;
#[cfg(feature = "l1")]
pub mod l1;
#[cfg(all(feature = "reliability", not(target_arch = "wasm32")))]
pub mod reliability;
pub use client::{CacheKit, CacheKitBuilder, SharedBackend, SwrRead, SwrToken};
pub use config::CachekitConfig;
pub use error::{BackendError, BackendErrorKind, CachekitError};
#[cfg(feature = "encryption")]
pub use client::SecureCache;
#[cfg(feature = "encryption")]
pub use encryption::EncryptionLayer;
#[cfg(feature = "macros")]
pub use cachekit_macros::cachekit;
pub use flight::SingleFlight;
#[cfg(all(feature = "reliability", not(target_arch = "wasm32")))]
pub use reliability::{BackpressureConfig, CircuitBreakerConfig, ReliabilityConfig, RetryConfig};
#[cfg(any(
feature = "l1",
all(feature = "reliability", not(target_arch = "wasm32"))
))]
pub(crate) fn random_unit() -> f64 {
let bits = uuid::Uuid::new_v4().as_u128() & ((1u128 << 53) - 1);
(bits as f64) / ((1u64 << 53) as f64)
}
#[cfg(all(feature = "l1", not(feature = "unsync"), not(target_arch = "wasm32")))]
#[doc(hidden)]
pub fn __swr_spawn<F>(fut: F)
where
F: std::future::Future<Output = ()> + Send + 'static,
{
if let Ok(handle) = tokio::runtime::Handle::try_current() {
drop(handle.spawn(fut));
}
}
#[cfg(not(all(feature = "l1", not(feature = "unsync"), not(target_arch = "wasm32"))))]
#[doc(hidden)]
pub fn __swr_spawn<F>(_fut: F)
where
F: std::future::Future<Output = ()> + 'static,
{
}
pub mod prelude {
pub use crate::{
BackendError, BackendErrorKind, CacheKit, CacheKitBuilder, CachekitConfig, CachekitError,
SwrRead, SwrToken,
};
#[cfg(feature = "encryption")]
pub use crate::{EncryptionLayer, SecureCache};
#[cfg(feature = "macros")]
pub use crate::cachekit;
}