pub struct CdnCache { /* private fields */ }
Expand description
Cache for CDN content following the standard CDN directory structure
Implementations§
Source§impl CdnCache
impl CdnCache
Sourcepub async fn for_product(product: &str) -> Result<Self>
pub async fn for_product(product: &str) -> Result<Self>
Create a CDN cache for a specific product
Sourcepub async fn with_base_dir(base_dir: PathBuf) -> Result<Self>
pub async fn with_base_dir(base_dir: PathBuf) -> Result<Self>
Create a CDN cache with a custom base directory
Sourcepub async fn with_cdn_path(cdn_path: &str) -> Result<Self>
pub async fn with_cdn_path(cdn_path: &str) -> Result<Self>
Create a CDN cache with a specific CDN path
Sourcepub fn set_cdn_path(&mut self, cdn_path: Option<String>)
pub fn set_cdn_path(&mut self, cdn_path: Option<String>)
Set the CDN path for this cache
Sourcepub fn config_dir(&self) -> PathBuf
pub fn config_dir(&self) -> PathBuf
Get the config cache directory
Sourcepub fn config_path(&self, hash: &str) -> PathBuf
pub fn config_path(&self, hash: &str) -> PathBuf
Construct a config cache path from a hash
Follows CDN structure: config/{first2}/{next2}/{hash}
Sourcepub fn data_path(&self, hash: &str) -> PathBuf
pub fn data_path(&self, hash: &str) -> PathBuf
Construct a data cache path from a hash
Follows CDN structure: data/{first2}/{next2}/{hash}
Sourcepub fn patch_path(&self, hash: &str) -> PathBuf
pub fn patch_path(&self, hash: &str) -> PathBuf
Construct a patch cache path from a hash
Follows CDN structure: patch/{first2}/{next2}/{hash}
Sourcepub fn index_path(&self, hash: &str) -> PathBuf
pub fn index_path(&self, hash: &str) -> PathBuf
Construct an index cache path from a hash
Follows CDN structure: data/{first2}/{next2}/{hash}.index
Sourcepub async fn has_config(&self, hash: &str) -> bool
pub async fn has_config(&self, hash: &str) -> bool
Check if a config exists in cache
Sourcepub async fn write_config(&self, hash: &str, data: &[u8]) -> Result<()>
pub async fn write_config(&self, hash: &str, data: &[u8]) -> Result<()>
Write config data to cache
Sourcepub async fn write_patch(&self, hash: &str, data: &[u8]) -> Result<()>
pub async fn write_patch(&self, hash: &str, data: &[u8]) -> Result<()>
Write patch data to cache
Sourcepub async fn open_data(&self, hash: &str) -> Result<File>
pub async fn open_data(&self, hash: &str) -> Result<File>
Stream read data from cache
Returns a file handle for efficient streaming
Sourcepub async fn write_configs_batch(
&self,
entries: &[(String, Vec<u8>)],
) -> Result<()>
pub async fn write_configs_batch( &self, entries: &[(String, Vec<u8>)], ) -> Result<()>
Write multiple config files in parallel
Sourcepub async fn write_data_batch(
&self,
entries: &[(String, Vec<u8>)],
) -> Result<()>
pub async fn write_data_batch( &self, entries: &[(String, Vec<u8>)], ) -> Result<()>
Write multiple data files in parallel
Sourcepub async fn read_configs_batch(
&self,
hashes: &[String],
) -> Vec<Result<Vec<u8>>> ⓘ
pub async fn read_configs_batch( &self, hashes: &[String], ) -> Vec<Result<Vec<u8>>> ⓘ
Read multiple config files in parallel
Sourcepub async fn read_data_batch(&self, hashes: &[String]) -> Vec<Result<Vec<u8>>> ⓘ
pub async fn read_data_batch(&self, hashes: &[String]) -> Vec<Result<Vec<u8>>> ⓘ
Read multiple data files in parallel
Sourcepub async fn has_configs_batch(&self, hashes: &[String]) -> Vec<bool>
pub async fn has_configs_batch(&self, hashes: &[String]) -> Vec<bool>
Check existence of multiple configs in parallel
Sourcepub async fn has_data_batch(&self, hashes: &[String]) -> Vec<bool>
pub async fn has_data_batch(&self, hashes: &[String]) -> Vec<bool>
Check existence of multiple data files in parallel