use once_cell::sync::Lazy;
use std::time::Duration;
use super::cache::EnvironmentCache;
use super::config::EnvCacheConfig;
pub static GLOBAL_ENV_CACHE: Lazy<EnvironmentCache> = Lazy::new(|| {
let config = EnvCacheConfig {
ttl: Duration::from_secs(
std::env::var("BSSH_ENV_CACHE_TTL")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(30),
),
enabled: std::env::var("BSSH_ENV_CACHE_ENABLED")
.map(|s| s.to_lowercase() != "false" && s != "0")
.unwrap_or(true),
max_entries: std::env::var("BSSH_ENV_CACHE_SIZE")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(50),
};
tracing::debug!(
"Initializing environment variable cache with {} max entries, {:?} TTL, enabled: {}",
config.max_entries,
config.ttl,
config.enabled
);
EnvironmentCache::with_config(config)
});