Skip to main content

kache_store/
config.rs

1use std::path::PathBuf;
2
3/// Options needed by local storage; remote and compiler settings stay with the caller.
4#[derive(Clone, Debug)]
5pub struct Config {
6    pub cache_dir: PathBuf,
7    pub max_size: u64,
8    pub gc_evict_shared: bool,
9    pub upload_spool_max_jobs: usize,
10    /// Store new entries without an fsync on the build path and flush them
11    /// later; a hit on an entry still pending verifies its bytes first.
12    pub deferred_durability: bool,
13}
14
15impl From<&Config> for Config {
16    fn from(config: &Config) -> Self {
17        config.clone()
18    }
19}
20
21impl Config {
22    pub fn store_dir(&self) -> PathBuf {
23        self.cache_dir.join("store")
24    }
25
26    pub fn upload_spool_dir(&self) -> PathBuf {
27        self.cache_dir.join("upload-queue")
28    }
29
30    pub fn index_db_path(&self) -> PathBuf {
31        self.cache_dir.join("index.db")
32    }
33}