use std::{path::PathBuf, time::Duration};
use rspack_paths::Utf8PathBuf;
pub use crate::legacy_cache::{BuildDepsOptions, PersistentCacheOptions, StorageOptions};
#[derive(Debug, Clone)]
pub enum CacheOptions {
Disabled,
Memory {
max_generations: u32,
},
FileSystem(FileSystemCacheOptions),
Persistent(PersistentCacheOptions),
}
#[derive(Debug, Clone)]
pub struct FileSystemCacheOptions {
pub build_dependencies: Vec<PathBuf>,
pub cache_directory: Utf8PathBuf,
pub cache_location: Utf8PathBuf,
pub version: String,
pub readonly: bool,
pub max_memory_generations: MaxMemoryGenerations,
pub idle_timeout: Duration,
pub idle_timeout_for_initial_store: Duration,
pub idle_timeout_after_large_changes: Duration,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MaxMemoryGenerations {
Disabled,
Infinity,
Finite(u32),
}
impl From<Option<u32>> for MaxMemoryGenerations {
fn from(value: Option<u32>) -> Self {
match value {
Some(0) => Self::Disabled,
Some(value) => Self::Finite(value),
None => Self::Infinity,
}
}
}