feat: totally updated cache structure using lru crate instead of moka (i.e., using simpler crate)
This commit is contained in:
parent
2477c6bf1b
commit
07d3accb91
10 changed files with 157 additions and 132 deletions
|
|
@ -36,6 +36,8 @@ pub struct Http3Option {
|
|||
#[derive(Deserialize, Debug, Default, PartialEq, Eq, Clone)]
|
||||
pub struct CacheOption {
|
||||
pub cache_dir: Option<String>,
|
||||
pub max_cache_entry: Option<usize>,
|
||||
pub max_cache_each_size: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Default, PartialEq, Eq, Clone)]
|
||||
|
|
@ -173,7 +175,15 @@ impl TryInto<ProxyConfig> for &ConfigToml {
|
|||
proxy_config.cache_dir = match &cache_option.cache_dir {
|
||||
Some(cache_dir) => Some(PathBuf::from(cache_dir)),
|
||||
None => Some(PathBuf::from(CACHE_DIR)),
|
||||
}
|
||||
};
|
||||
proxy_config.cache_max_entry = match &cache_option.max_cache_entry {
|
||||
Some(num) => Some(*num),
|
||||
None => Some(MAX_CACHE_ENTRY),
|
||||
};
|
||||
proxy_config.cache_max_each_size = match &cache_option.max_cache_each_size {
|
||||
Some(num) => Some(*num),
|
||||
None => Some(MAX_CACHE_EACH_SIZE),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,12 @@
|
|||
pub const LISTEN_ADDRESSES_V4: &[&str] = &["0.0.0.0"];
|
||||
pub const LISTEN_ADDRESSES_V6: &[&str] = &["[::]"];
|
||||
pub const CONFIG_WATCH_DELAY_SECS: u32 = 20;
|
||||
|
||||
// Cache directory
|
||||
pub const CACHE_DIR: &str = "./cache";
|
||||
// # of entries in cache
|
||||
pub const MAX_CACHE_ENTRY: usize = 1_000;
|
||||
// max size for each file in bytes
|
||||
pub const MAX_CACHE_EACH_SIZE: usize = 65_535;
|
||||
|
||||
// TODO: max cache size in total
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue