Interface IResourceStoreManager.IVersionedResourceStoreWithVersionExtractorBase<Key,Value>
- Type Parameters:
Key- The type of the key.Value- The type of the derived value.
- All Superinterfaces:
IResourceStoreManager.IVersionedResourceStoreBase<Key,Value>
- All Known Subinterfaces:
IResourceStoreManager.IVersionedResourceStoreWithLoaderAndVersionExtractor<Key,Value>, IResourceStoreManager.IVersionedResourceStoreWithVersionExtractor<Key, Value>
- Enclosing interface:
IResourceStoreManager
public static interface IResourceStoreManager.IVersionedResourceStoreWithVersionExtractorBase<Key,Value>
extends IResourceStoreManager.IVersionedResourceStoreBase<Key,Value>
Same as
IResourceStoreManager.IVersionedResourceStore, but with a bound version extractor that does not need to be specified
each time when requesting a value for a key.- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent(Key key, ISerializableThrowingFunction<? super Key, ? extends Value> loader) Gets the value for the given key.getIfPresent(Key key) Gets the value associated with the given key.removeAndGetIfPresent(Key key) Removes the value associated with the given key, if it matches the expected version from the bound version extractor.Methods inherited from interface IResourceStoreManager.IVersionedResourceStoreBase
computeIfAbsent, getIfPresent, remove, removeAndGetIfPresent
-
Method Details
-
computeIfAbsent
Value computeIfAbsent(Key key, ISerializableThrowingFunction<? super Key, ? extends Value> loader) throws IOException Gets the value for the given key. The version controls whether the value is still valid. If the version obtained from the bound version extractor is different from the stored version of the file, the value is considered stale. Stales values are discarded and reloaded using the given loader.- Parameters:
key- The key for which to get the value.loader- The loader to use if the value does not exist or is stale.- Returns:
- The associated value, either from the store if still fresh, or obtained from the bound loader.
- Throws:
IOException- If the loader throws an exception.
-
getIfPresent
Gets the value associated with the given key. Returns null if no value exists yet. If the value exists, but is stale (i.e. does not match the version as obtained from the bound version extractor), it will be removed.- Parameters:
key- The key to get the value for.- Returns:
- The associated value, if present and up-to-date, or null if no value exists or does not match the version.
-
removeAndGetIfPresent
Removes the value associated with the given key, if it matches the expected version from the bound version extractor. Returns null if no value exists yet. If the value exists, but is stale (i.e. does not match the version), it will be removed. The value returned by this method will NOT be closed if it implementsAutoCloseable.- Parameters:
key- The key to get the value for.- Returns:
- The associated value, if present and up-to-date, or null if no value exists or does not match the version.
-