#[cfg(feature = "batch-write")]
pub mod batch_writer;
#[cfg(feature = "batch-write")]
pub mod common;
#[cfg(feature = "batch-write")]
pub mod invalidation;
#[cfg(feature = "batch-write")]
pub mod optimized_batch_writer;
#[cfg(feature = "batch-write")]
pub mod promotion;
#[cfg(feature = "batch-write")]
pub mod warmup;
#[cfg(not(feature = "batch-write"))]
pub(crate) mod batch_writer;
#[cfg(not(feature = "batch-write"))]
pub(crate) mod common;
#[cfg(not(feature = "batch-write"))]
pub(crate) mod invalidation;
#[cfg(not(feature = "batch-write"))]
pub(crate) mod optimized_batch_writer;
#[cfg(not(feature = "batch-write"))]
pub(crate) mod promotion;
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub struct BatchWriterConfig {
pub max_buffer_size: usize,
pub max_batch_size: usize,
pub flush_interval_ms: u64,
}
#[cfg(not(feature = "batch-write"))]
impl BatchWriterConfig {
pub fn new(max_buffer_size: usize, max_batch_size: usize, flush_interval_ms: u64) -> Self {
Self {
max_buffer_size,
max_batch_size,
flush_interval_ms,
}
}
}
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub enum BatchOperation {
#[default]
Set,
Delete,
}
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub struct BatchWriter;
#[cfg(not(feature = "batch-write"))]
impl BatchWriter {
pub fn new(
_service_name: String,
_l2: std::sync::Arc<crate::backend::l2::L2Backend>,
_config: BatchWriterConfig,
) -> Self {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub fn new_with_default_config(
_service_name: String,
_l2: std::sync::Arc<crate::backend::l2::L2Backend>,
) -> Self {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn shutdown(&self) {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn start(&self) {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn enqueue(&self, _key: String, _value: Vec<u8>, _ttl: Option<u64>) -> Result<()> {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn enqueue_delete(&self, _key: String) -> Result<()> {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn enqueue_operation(&self, _operation: BatchOperation) -> Result<()> {
panic!(
"BatchWriter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
}
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub struct InvalidationConfig;
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub struct CacheInvalidator;
#[cfg(not(feature = "batch-write"))]
impl CacheInvalidator {
pub fn new(_config: InvalidationConfig) -> Self {
panic!(
"CacheInvalidator requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn invalidate(&self, _key: &str) -> Result<()> {
panic!(
"CacheInvalidator requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn invalidate_pattern(&self, _pattern: &str) -> Result<()> {
panic!(
"CacheInvalidator requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn invalidate_all(&self) -> Result<()> {
panic!(
"CacheInvalidator requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
}
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub struct PromotionConfig;
#[cfg(not(feature = "batch-write"))]
#[derive(Debug, Clone, Default)]
pub struct CachePromoter;
#[cfg(not(feature = "batch-write"))]
impl CachePromoter {
pub fn new(_config: PromotionConfig) -> Self {
panic!(
"CachePromoter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn promote(&self, _key: &str) -> Result<()> {
panic!(
"CachePromoter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
pub async fn promote_many(&self, _keys: &[String]) -> Result<()> {
panic!(
"CachePromoter requires the 'batch-write' feature to be enabled. \
\n\n\
Solution 1: Enable the batch-write feature:\n\
oxcache = {{ version = \"0.2\", features = [\"batch-write\"] }}\n\
\n\
Solution 2: Enable all features:\n\
oxcache = {{ version = \"0.2\", features = [\"full\"] }}"
);
}
}