e478cc4
use lombok::{Builder, Getter, Setter};
#[derive(
serde::Deserialize, serde::Serialize, Debug, Clone, PartialEq, Eq, Getter, Setter, Builder,
)]
#[serde(default)]
pub struct AppCacheSettings {
pub enabled: bool,
pub ttl_seconds: u64,
pub max_capacity: usize,
pub max_size: usize,
pub enable_disk: bool,
pub disk_path: Option<String>,
pub disk_cache_max_size: usize,
pub disk_cache_max_capacity: usize,
}
impl Default for AppCacheSettings {
fn default() -> Self {
Self {
enabled: true,
ttl_seconds: 300,
max_capacity: 10_000,
max_size: 50_000_000,
enable_disk: false,
disk_path: None,
disk_cache_max_size: 200_000_000,
disk_cache_max_capacity: 100_000,
}
}
}
#[derive(
Debug, serde::Deserialize, serde::Serialize, Clone, PartialEq, Eq, Getter, Setter, Builder,
)]
#[serde(default)]
pub struct AppRedisSettings {
pub urls: Vec<String>,
pub mode: AppRedisMode,
pub connection_timeout_ms: Option<u64>,
pub response_timeout_ms: Option<u64>,
pub password: Option<String>,
pub database: Option<i64>,
}
#[derive(serde::Deserialize, serde::Serialize, Debug, Clone, PartialEq, Eq, Default)]
pub enum AppRedisMode {
#[default]
Single,
Cluster,
Sentinel,
}
impl Default for AppRedisSettings {
fn default() -> Self {
Self {
urls: vec!["redis://127.0.0.1:6379".to_string()],
mode: AppRedisMode::default(),
connection_timeout_ms: Some(2_000),
response_timeout_ms: Some(5_000),
password: None,
database: Some(0),
}
}
}