pub struct Cache { /* private fields */ }Expand description
Docker 镜像缓存管理
提供本地缓存功能,结构与 Docker Registry API 兼容,支持从 repository 或 tar 文件 获取 manifest 和 blob,并支持从缓存中推送。
缓存结构:
.cache/
manifests/{repository}/{reference}
blobs/sha256/{digest}
index.json // 缓存索引Implementations§
Source§impl Cache
impl Cache
Sourcepub fn save_manifest(
&mut self,
repository: &str,
reference: &str,
manifest: &[u8],
config_digest: &str,
) -> Result<PathBuf>
pub fn save_manifest( &mut self, repository: &str, reference: &str, manifest: &[u8], config_digest: &str, ) -> Result<PathBuf>
保存清单(manifest)到缓存
Sourcepub fn save_blob(
&mut self,
digest: &str,
data: &[u8],
_is_config: bool,
_compressed: bool,
) -> Result<PathBuf>
pub fn save_blob( &mut self, digest: &str, data: &[u8], _is_config: bool, _compressed: bool, ) -> Result<PathBuf>
保存 blob 到缓存
Sourcepub fn associate_blob_with_image(
&mut self,
repository: &str,
reference: &str,
digest: &str,
size: u64,
is_config: bool,
compressed: bool,
) -> Result<()>
pub fn associate_blob_with_image( &mut self, repository: &str, reference: &str, digest: &str, size: u64, is_config: bool, compressed: bool, ) -> Result<()>
将 blob 关联到指定的镜像
Sourcepub fn add_blob(
&mut self,
digest: &str,
data: &[u8],
_is_config: bool,
_compressed: bool,
) -> Result<PathBuf>
pub fn add_blob( &mut self, digest: &str, data: &[u8], _is_config: bool, _compressed: bool, ) -> Result<PathBuf>
Add a blob to the cache
Sourcepub fn get_blob_path(&self, digest: &str) -> PathBuf
pub fn get_blob_path(&self, digest: &str) -> PathBuf
Get blob path from digest
Sourcepub fn get_manifest(&self, repository: &str, reference: &str) -> Result<Vec<u8>>
pub fn get_manifest(&self, repository: &str, reference: &str) -> Result<Vec<u8>>
从缓存中获取 manifest
Sourcepub fn remove_manifest(
&mut self,
repository: &str,
reference: &str,
) -> Result<()>
pub fn remove_manifest( &mut self, repository: &str, reference: &str, ) -> Result<()>
删除清单及其未被其他镜像引用的 blob
Sourcepub fn list_manifests(&self) -> Vec<(String, String)>
pub fn list_manifests(&self) -> Vec<(String, String)>
列出缓存中的所有清单
Sourcepub fn get_stats(&self) -> Result<CacheStats>
pub fn get_stats(&self) -> Result<CacheStats>
获取缓存统计信息
Sourcepub fn get_blob_size(&self, digest: &str) -> Option<u64>
pub fn get_blob_size(&self, digest: &str) -> Option<u64>
从缓存中获取blob大小
Sourcepub fn get_image_blobs(
&self,
repository: &str,
reference: &str,
) -> Result<Vec<BlobInfo>>
pub fn get_image_blobs( &self, repository: &str, reference: &str, ) -> Result<Vec<BlobInfo>>
获取镜像的所有blob信息
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
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
Mutably borrows from an owned value. Read more