pub struct LayerCache { /* private fields */ }Expand description
Content-addressed cache for extracted OCI layers.
Layers are stored by digest under cache_dir/layers/<digest>/.
Metadata is stored alongside as <digest>.meta.json.
Implementations§
Source§impl LayerCache
impl LayerCache
Sourcepub fn get(&self, digest: &str) -> Result<Option<PathBuf>>
pub fn get(&self, digest: &str) -> Result<Option<PathBuf>>
Get the path to a cached layer by digest.
Returns None if the layer is not cached or the cache entry is invalid.
Sourcepub fn put(&self, digest: &str, source_dir: &Path) -> Result<PathBuf>
pub fn put(&self, digest: &str, source_dir: &Path) -> Result<PathBuf>
Store an extracted layer directory in the cache.
Copies the contents of source_dir into the cache keyed by digest.
Returns the path to the cached layer directory.
Sourcepub fn invalidate(&self, digest: &str) -> Result<()>
pub fn invalidate(&self, digest: &str) -> Result<()>
Remove a cached layer by digest.
Sourcepub fn prune(&self, max_bytes: u64) -> Result<usize>
pub fn prune(&self, max_bytes: u64) -> Result<usize>
Prune the cache to stay within the given byte limit.
Evicts least-recently-accessed entries first. Returns the number of entries evicted.
Sourcepub fn list_entries(&self) -> Result<Vec<LayerMeta>>
pub fn list_entries(&self) -> Result<Vec<LayerMeta>>
List all cached layer entries with their metadata.
Sourcepub fn total_size(&self) -> Result<u64>
pub fn total_size(&self) -> Result<u64>
Get the total size of all cached layers in bytes.
Trait Implementations§
Source§impl CacheBackend for LayerCache
impl CacheBackend for LayerCache
Source§fn get(&self, key: &str) -> Result<Option<PathBuf>>
fn get(&self, key: &str) -> Result<Option<PathBuf>>
Retrieve a cached directory by key. Read more
Source§fn put(
&self,
key: &str,
source_dir: &Path,
_description: &str,
) -> Result<PathBuf>
fn put( &self, key: &str, source_dir: &Path, _description: &str, ) -> Result<PathBuf>
Store a directory tree in the cache under the given key. Read more
Auto Trait Implementations§
impl Freeze for LayerCache
impl RefUnwindSafe for LayerCache
impl Send for LayerCache
impl Sync for LayerCache
impl Unpin for LayerCache
impl UnsafeUnpin for LayerCache
impl UnwindSafe for LayerCache
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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