Interface InfoCache
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Deletes all cached infos.fetchInfo
(Identifier identifier) Reads the cached image information corresponding to the given identifier.void
put
(Identifier identifier, Info info) Synchronously adds image information to the cache.void
put
(Identifier identifier, String info) Alternative toput(Identifier, Info)
that adds a raw UTF-8 string to the cache, trusting that it is a serializedInfo
instance that is deserializable byfetchInfo(Identifier)
.Methods inherited from interface is.galia.cache.Cache
addObserver, cleanUp, evict, evictInvalid, initialize, onCacheWorker, purge, shutdown
-
Method Details
-
evictInfos
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
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
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
Alternative to
put(Identifier, Info)
that adds a raw UTF-8 string to the cache, trusting that it is a serializedInfo
instance that is deserializable byfetchInfo(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) fromInfo.toJSON()
.- Throws:
IOException
-