pub struct PackageCache { /* private fields */ }Expand description
High-performance package payload cache.
This struct manages a disk-based cache of package variant payloads, enabling fast environment resolution without fetching from shared storage.
§Example
use rez_next_package::package_cache::PackageCache;
let cache = PackageCache::new("/path/to/cache").unwrap();Implementations§
Source§impl PackageCache
impl PackageCache
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<Self, PackageCacheError>
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self, PackageCacheError>
Create a new package cache at the given root path.
§Errors
Returns PackageCacheError::NotADirectory if path is not an existing directory.
Sourcepub fn with_config<P: AsRef<Path>>(
path: P,
config: CacheConfig,
) -> Result<Self, PackageCacheError>
pub fn with_config<P: AsRef<Path>>( path: P, config: CacheConfig, ) -> Result<Self, PackageCacheError>
Create with custom configuration.
Sourcepub fn config(&self) -> &CacheConfig
pub fn config(&self) -> &CacheConfig
Get the configuration.
Sourcepub fn get_cached_root(
&self,
handle: &VariantHandle,
) -> (CacheStatus, Option<PathBuf>)
pub fn get_cached_root( &self, handle: &VariantHandle, ) -> (CacheStatus, Option<PathBuf>)
Check if a variant is cached and return its root path.
Updates the last-accessed time on the cache entry.
§Returns
(CacheStatus, Option<PathBuf>) - status and path if found.
Sourcepub fn add_variant(
&self,
handle: &VariantHandle,
source_root: &Path,
force: bool,
) -> Result<(CacheStatus, PathBuf), PackageCacheError>
pub fn add_variant( &self, handle: &VariantHandle, source_root: &Path, force: bool, ) -> Result<(CacheStatus, PathBuf), PackageCacheError>
Sourcepub fn remove_variant(
&self,
handle: &VariantHandle,
) -> (CacheStatus, Option<PathBuf>)
pub fn remove_variant( &self, handle: &VariantHandle, ) -> (CacheStatus, Option<PathBuf>)
Remove a variant from the cache.
Moves the payload to the to_delete directory; actual deletion
happens during clean().
Sourcepub fn list_cached(&self) -> Vec<(VariantHandle, PathBuf, CacheStatus)>
pub fn list_cached(&self) -> Vec<(VariantHandle, PathBuf, CacheStatus)>
List all cached variants.
Returns a list of (handle, path, status) tuples.
Sourcepub fn clean(&self, time_limit_secs: Option<u64>) -> CleanStats
pub fn clean(&self, time_limit_secs: Option<u64>) -> CleanStats
Clean the cache by removing:
- Old unused entries (based on
max_age_secs) - Stalled copies
- Entries in to_delete directory
§Arguments
time_limit_secs- Optional time limit for cleaning operation
Sourcepub fn cache_near_full(&self) -> bool
pub fn cache_near_full(&self) -> bool
Check if the cache disk is near full.
Returns true if available space is below min_free_space_bytes.
Aligns with rez.package_cache.PackageCache.cache_near_full().
Sourcepub fn variant_meets_space_requirements(&self, variant_root: &Path) -> bool
pub fn variant_meets_space_requirements(&self, variant_root: &Path) -> bool
Auto Trait Implementations§
impl Freeze for PackageCache
impl RefUnwindSafe for PackageCache
impl Send for PackageCache
impl Sync for PackageCache
impl Unpin for PackageCache
impl UnsafeUnpin for PackageCache
impl UnwindSafe for PackageCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more