@Immutable public class Cache extends Object
This class is immutable and safe to use across threads.
| Modifier and Type | Method and Description |
|---|---|
Optional<CachedLayer> |
retrieve(DescriptorDigest layerDigest)
Retrieves the
CachedLayer for the layer with digest layerDigest. |
Optional<CachedLayer> |
retrieve(com.google.common.collect.ImmutableList<LayerEntry> layerEntries)
Retrieves the
CachedLayer that was built from the layerEntries. |
Optional<ManifestAndConfig> |
retrieveMetadata(ImageReference imageReference)
Retrieves the cached manifest and container configuration for an image reference.
|
static Cache |
withDirectory(Path cacheDirectory)
Initializes the cache using
cacheDirectory for storage. |
CachedLayer |
writeCompressedLayer(Blob compressedLayerBlob)
Saves a cache entry with a compressed layer
Blob. |
void |
writeMetadata(ImageReference imageReference,
BuildableManifestTemplate manifestTemplate,
ContainerConfigurationTemplate containerConfigurationTemplate)
Saves a manifest and container configuration for a V2.2 or OCI image.
|
void |
writeMetadata(ImageReference imageReference,
V21ManifestTemplate manifestTemplate)
Saves a V2.1 image manifest.
|
CachedLayer |
writeUncompressedLayer(Blob uncompressedLayerBlob,
com.google.common.collect.ImmutableList<LayerEntry> layerEntries)
Saves a cache entry with an uncompressed layer
Blob and an additional selector digest. |
public static Cache withDirectory(Path cacheDirectory) throws IOException
cacheDirectory for storage.cacheDirectory - the directory for the cache. Creates the directory if it does not exist.CacheIOException - if an I/O exception occurspublic void writeMetadata(ImageReference imageReference, BuildableManifestTemplate manifestTemplate, ContainerConfigurationTemplate containerConfigurationTemplate) throws IOException
imageReference - the image reference to save the manifest and container configuration formanifestTemplate - the V2.2 or OCI manifestcontainerConfigurationTemplate - the container configurationIOException - if an I/O exception occurspublic void writeMetadata(ImageReference imageReference, V21ManifestTemplate manifestTemplate) throws IOException
imageReference - the image reference to save the manifest and container configuration formanifestTemplate - the V2.1 manifestIOException - if an I/O exception occurspublic CachedLayer writeCompressedLayer(Blob compressedLayerBlob) throws IOException
Blob. Use writeUncompressedLayer(Blob, ImmutableList) to save a cache entry with an uncompressed layer
Blob and include a selector.compressedLayerBlob - the compressed layer BlobCachedLayer for the written layerIOException - if an I/O exception occurspublic CachedLayer writeUncompressedLayer(Blob uncompressedLayerBlob, com.google.common.collect.ImmutableList<LayerEntry> layerEntries) throws IOException
Blob and an additional selector digest.
Use writeCompressedLayer(Blob) to save a compressed layer Blob.uncompressedLayerBlob - the layer BloblayerEntries - the layer entries that make up the layerCachedLayer for the written layerIOException - if an I/O exception occurspublic Optional<ManifestAndConfig> retrieveMetadata(ImageReference imageReference) throws IOException, CacheCorruptedException
imageReference - the image referenceIOException - if an I/O exception occursCacheCorruptedException - if the cache is corruptedpublic Optional<CachedLayer> retrieve(com.google.common.collect.ImmutableList<LayerEntry> layerEntries) throws IOException, CacheCorruptedException
CachedLayer that was built from the layerEntries.layerEntries - the layer entries to match againstCachedLayer that was built from layerEntries, if foundIOException - if an I/O exception occursCacheCorruptedException - if the cache is corruptedpublic Optional<CachedLayer> retrieve(DescriptorDigest layerDigest) throws IOException, CacheCorruptedException
CachedLayer for the layer with digest layerDigest.layerDigest - the layer digestCachedLayer referenced by the layer digest, if foundCacheCorruptedException - if the cache was found to be corruptedIOException - if an I/O exception occursCopyright © 2019. All rights reserved.