Interface InfoCache

All Superinterfaces:
Cache
All Known Implementing Classes:
HeapCache

public non-sealed interface InfoCache extends Cache
Caches image information.
  • Method Details

    • evictInfos

      void evictInfos() throws IOException
      Deletes all cached infos.
      Throws:
      IOException - upon fatal error. Implementations should do the best they can to complete the operation and swallow and log non-fatal errors.
    • fetchInfo

      Optional<Info> fetchInfo(Identifier identifier) throws IOException

      Reads the cached image information corresponding to the given identifier.

      If invalid image information exists in the cache, implementations should delete it—ideally asynchronously.

      Parameters:
      identifier - Image identifier for which to retrieve information.
      Returns:
      Info corresponding to the given identifier, or Optional.empty() if no such instance exists.
      Throws:
      IOException
    • put

      void put(Identifier identifier, Info info) throws IOException

      Synchronously adds image information to the cache.

      If the information corresponding to the given identifier already exists, it will be overwritten.

      Parameters:
      identifier - Image identifier.
      info - Information about the image corresponding with the given identifier.
      Throws:
      IOException
    • put

      void put(Identifier identifier, String info) throws IOException

      Alternative to put(Identifier, Info) that adds a raw UTF-8 string to the cache, trusting that it is a serialized Info instance that is deserializable by fetchInfo(Identifier).

      This method is used for testing. put(Identifier, Info) should normally be used instead.

      Parameters:
      identifier - Image identifier.
      info - JSON-encoded information about the image corresponding with the given identifier, obtained (for example) from Info.toJSON().
      Throws:
      IOException