Example #1
0
        /**
         * Saves a cache entry with an uncompressed layer {@link Blob} and an additional selector digest.
         * Use {@link #writeCompressedLayer(Blob)} to save a compressed layer {@link Blob}.
         *
         * @param uncompressedLayerBlob the layer {@link Blob}
         * @param layerEntries the layer entries that make up the layer
         * @return the {@link CachedLayer} for the written layer
         * @throws IOException if an I/O exception occurs
         */
        public async Task <CachedLayer> WriteUncompressedLayerAsync(
            IBlob uncompressedLayerBlob, ImmutableArray <LayerEntry> layerEntries)
        {
            DescriptorDigest selector = await LayerEntriesSelector.GenerateSelectorAsync(layerEntries).ConfigureAwait(false);

            return(await cacheStorageWriter.WriteUncompressedAsync(
                       uncompressedLayerBlob, selector).ConfigureAwait(false));
        }
Example #2
0
        /**
         * Retrieves the {@link CachedLayer} that was built from the {@code layerEntries}.
         *
         * @param layerEntries the layer entries to match against
         * @return a {@link CachedLayer} that was built from {@code layerEntries}, if found
         * @throws IOException if an I/O exception occurs
         * @throws CacheCorruptedException if the cache is corrupted
         */
        public async Task <Maybe <CachedLayer> > RetrieveAsync(ImmutableArray <LayerEntry> layerEntries)
        {
            DescriptorDigest selector = await LayerEntriesSelector.GenerateSelectorAsync(layerEntries).ConfigureAwait(false);

            Maybe <DescriptorDigest> optionalSelectedLayerDigest = cacheStorageReader.Select(selector);

            if (!optionalSelectedLayerDigest.IsPresent())
            {
                return(Maybe.Empty <CachedLayer>());
            }

            return(cacheStorageReader.Retrieve(optionalSelectedLayerDigest.Get()));
        }