pub mod cleanup;
pub mod namespace;
pub mod paths;
pub mod resolve;
use super::NormalizedPath;
pub const CACHE_DIR_ENV: &str = "ZCCACHE_CACHE_DIR";
pub const DAEMON_NAMESPACE_ENV: &str = "ZCCACHE_DAEMON_NAMESPACE";
pub const DEFAULT_DAEMON_NAMESPACE: &str = "default";
pub const DEV_DAEMON_NAMESPACE: &str = "dev";
pub const DEFAULT_IDLE_TIMEOUT_SECS: u64 = 3600;
pub const COLOCATE_ENV: &str = "ZCCACHE_COLOCATE";
pub use cleanup::{cleanup_legacy_temp_root_state, cleanup_stale_depfile_dirs};
pub use namespace::{
daemon_namespace, daemon_namespace_label, sanitize_daemon_namespace, sanitize_ipc_component,
};
pub use paths::{
artifacts_dir, artifacts_dir_from_cache_dir, cargo_registry_cache_dir,
cargo_registry_cache_dir_from_cache_dir, compiler_hash_cache_path_from_cache_dir,
crash_dump_dir, depfile_dir, depfile_dir_from_cache_dir, depgraph_dir, index_path,
index_path_from_cache_dir, log_dir, log_dir_from_cache_dir, metadata_path_from_cache_dir,
symbols_cache_dir, symbols_cache_dir_from_cache_dir, system_includes_cache_path_from_cache_dir,
tmp_dir, tmp_dir_from_cache_dir,
};
pub use resolve::{
cache_dir_override, default_cache_dir, effective_cache_root_from_top_level, resolve_cache_root,
resolve_cache_root_top_level, versioned_subdir, CacheRootSource,
};
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(default)]
pub struct Config {
pub cache_dir: NormalizedPath,
pub max_cache_size: u64,
pub idle_timeout_secs: u64,
pub enable_watcher: bool,
pub watcher_poll_fallback: bool,
pub log_level: String,
pub max_memory_bytes: u64,
pub eviction_interval_secs: u64,
pub disk_gc_interval_secs: u64,
}
impl Default for Config {
fn default() -> Self {
Self {
cache_dir: default_cache_dir(),
max_cache_size: 10 * 1024 * 1024 * 1024, idle_timeout_secs: DEFAULT_IDLE_TIMEOUT_SECS,
enable_watcher: true,
watcher_poll_fallback: false,
log_level: String::from("info"),
max_memory_bytes: 1_073_741_824, eviction_interval_secs: 30,
disk_gc_interval_secs: 300,
}
}
}
#[cfg(test)]
mod tests;