pub struct BlobCache { /* private fields */ }Expand description
Local blob cache for OCI images (in-memory)
Implementations§
Source§impl BlobCache
impl BlobCache
Sourcepub fn new() -> Result<Self, CacheError>
pub fn new() -> Result<Self, CacheError>
Sourcepub fn open<P: AsRef<Path>>(_path: P) -> Result<Self, CacheError>
pub fn open<P: AsRef<Path>>(_path: P) -> Result<Self, CacheError>
Open or create a cache at the given path (creates in-memory for now)
§Errors
Returns CacheError if the cache cannot be initialized.
Sourcepub fn with_max_size(self, max_size_bytes: u64) -> Self
pub fn with_max_size(self, max_size_bytes: u64) -> Self
Set maximum cache size in bytes
Sourcepub fn put(&self, digest: &str, data: &[u8]) -> Result<(), CacheError>
pub fn put(&self, digest: &str, data: &[u8]) -> Result<(), CacheError>
Put a blob into the cache
§Errors
Returns CacheError if the digest is invalid, mismatched, or the lock is poisoned.
Sourcepub fn contains(&self, digest: &str) -> Result<bool, CacheError>
pub fn contains(&self, digest: &str) -> Result<bool, CacheError>
Check if a blob exists in the cache
§Errors
Returns CacheError if the digest is invalid or the lock is poisoned.
Sourcepub fn delete(&self, digest: &str) -> Result<(), CacheError>
pub fn delete(&self, digest: &str) -> Result<(), CacheError>
Delete a blob from the cache
§Errors
Returns CacheError if the digest is invalid or the lock is poisoned.
Sourcepub fn size(&self) -> Result<u64, CacheError>
pub fn size(&self) -> Result<u64, CacheError>
Trait Implementations§
Source§impl BlobCacheBackend for BlobCache
impl BlobCacheBackend for BlobCache
Source§fn put_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
digest: &'life1 str,
src: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put_path<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
digest: &'life1 str,
src: &'life2 Path,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Ingest a file into the in-memory cache, but ONLY when it is small.
An in-memory cache holding a value means holding its bytes in RAM — the
exact thing the streaming pull path avoids for large layers. So a blob
larger than Self::MAX_INMEM_INGEST is skipped (the on-disk file the
caller already has remains the source of truth); small blobs are read in
and cached as usual. The file-backed [crate::PersistentBlobCache]
overrides this with a zero-copy hardlink and has no such cap.
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
digest: &'life1 str,
data: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
digest: &'life1 str,
data: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn contains<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn contains<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn keys_with_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn keys_with_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
prefix. Read moreSource§fn get_size<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_size<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_path<'life0, 'life1, 'async_trait>(
&'life0 self,
_digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<PathBuf>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_path<'life0, 'life1, 'async_trait>(
&'life0 self,
_digest: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<PathBuf>, CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
None for in-memory / inline / remote
backends — callers must then fall back to BlobCacheBackend::get. Read moreSource§fn compact<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn compact<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), CacheError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
SQLite freelist pages left behind by deletes/evictions, which keep the
on-disk file large even after the rows are gone). Read more