class CacheStorageReader {

  Optional<ImageMetadataTemplate> retrieveMetadata(ImageReference imageReference)
      throws IOException, CacheCorruptedException {
    Path imageDirectory = cacheStorageFiles.getImageDirectory(imageReference);
    Path metadataPath = imageDirectory.resolve("manifests_configs.json");
    if (!Files.exists(metadataPath)) {
      return Optional.empty();
    }

    ImageMetadataTemplate metadata;
    try (LockFile ignored = LockFile.lock(imageDirectory.resolve("lock"))) {
      metadata = JsonTemplateMapper.readJsonFromFile(metadataPath, ImageMetadataTemplate.class);
    }
    verifyImageMetadata(metadata, imageDirectory);
    return Optional.of(metadata);
  }

    CacheStorageReader(CacheStorageFiles cacheStorageFiles);

}