#![doc(html_root_url = "https://docs.rs/oxcache/0.2.0")]
#![deny(unsafe_code)]
#[macro_export]
macro_rules! check_feature_dependence {
($required:expr, $dependent:expr) => {
#[cfg(all(feature = $dependent, not(feature = $required), not(feature = "full")))]
compile_error!(concat!(
"Feature '",
$dependent,
"' requires '",
$required,
"' or 'full' feature.\n",
"\nSolution 1: Enable required feature:\n",
" oxcache = { version = \"0.1\", features = [\"",
$dependent,
"\", \"",
$required,
"\"] }\n",
"\nSolution 2: Enable all features:\n",
" oxcache = { version = \"0.1\", features = [\"full\"] }"
));
};
}
pub mod core;
pub mod error;
#[doc(hidden)]
pub mod internal;
pub mod cache;
#[cfg(any(
feature = "memory",
feature = "redis",
feature = "minimal",
feature = "core",
feature = "full"
))]
pub mod backend;
pub mod features;
#[cfg(any(
feature = "metrics",
feature = "memory",
feature = "redis",
feature = "minimal",
feature = "core",
feature = "full",
feature = "batch-write",
feature = "cli"
))]
pub mod infra;
#[cfg(test)]
mod testing;
pub mod registry;
pub mod traits;
pub mod config;
pub mod utils;
pub(crate) mod security;
#[cfg(feature = "macros")]
pub use oxcache_macros::cached;
#[cfg(feature = "macros")]
pub mod macros {
pub use oxcache_macros::*;
}
pub use error::{CacheConfigError, CacheError, ConfigResult, Result};
#[doc(hidden)]
pub use crate::internal::__internal_get_cache;
pub use cache::builder::CacheBuilder;
pub use cache::Cache;
#[cfg(any(feature = "metrics", feature = "full"))]
pub use infra::{export_json_format, export_prometheus_format, get_enhanced_stats, CacheStats};
#[cfg(any(feature = "redis", feature = "full"))]
pub use crate::security::{
clamp_scan_count,
log::{log_cache_key, sanitize_message},
redaction::{redact_cache_key, redact_connection_string, redact_field, redact_value, Redacted},
validate_lua_script, validate_redis_key, validate_scan_pattern,
};
pub use cache::chain::{ChainCache, ChainCacheBuilder, ChainLink};
pub use cache::interface::UnifiedCache;
pub use traits::CacheKey;
pub use core::types::{BackendType, CacheLayer, RedisModeType, SerializationType};
pub use crate::utils::KeyGenerator;
pub use core::events::{CacheEvent, CacheEventType, EventPublisher};
pub use backend::{
dashmap_memory, default_memory_backend, moka_memory, BackendScore, DashMapMemoryBackend, MemoryBackendType,
MokaMemoryBackend, Scores,
};
#[cfg(feature = "redis")]
pub use backend::{RedisBackend, RedisBackendBuilder, RedisMode};
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(test)]
mod tests {
use crate::VERSION;
#[test]
fn test_check_feature_dependence_macro_no_error() {
check_feature_dependence!("memory", "redis");
}
#[test]
fn test_check_feature_dependence_macro_same_feature() {
check_feature_dependence!("memory", "memory");
}
#[test]
fn test_version_constant() {
assert!(!VERSION.is_empty());
}
#[test]
fn test_version_format() {
assert!(VERSION.chars().any(|c: char| c.is_ascii_digit()));
}
}