Interface IResourceStoreManager.IVersionedResourceStoreBase<Key,Value>
-
- Type Parameters:
Key
- The type of the key.Value
- The type of the associated value.
- All Known Subinterfaces:
IResourceStoreManager.IVersionedResourceStore<Key,Value>
,IResourceStoreManager.IVersionedResourceStoreWithLoader<Key,Value>
,IResourceStoreManager.IVersionedResourceStoreWithLoaderAndVersionExtractor<Key,Value>
,IResourceStoreManager.IVersionedResourceStoreWithLoaderBase<Key,Value>
,IResourceStoreManager.IVersionedResourceStoreWithVersionExtractor<Key,Value>
,IResourceStoreManager.IVersionedResourceStoreWithVersionExtractorBase<Key,Value>
- Enclosing interface:
- IResourceStoreManager
public static interface IResourceStoreManager.IVersionedResourceStoreBase<Key,Value>
Manages values associated with a certain type of key. Each key can be associated with a value, such as e.g. a file with a thumbnail. Each key has a version, which is used to determine whether the value is still valid, e.g. a thumbnail is considered stale if the file was modified after the thumbnail was created. Stale values will be removed and loaded again using a loader.- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Value
computeIfAbsent(Key key, Object version, ISerializableThrowingFunction<? super Key,? extends Value> loader)
Gets the value associated with the given key.Value
getIfPresent(Key key, Object version)
Gets the value associated with the given key.void
remove(Key key)
Removes the associated value form this store.Value
removeAndGetIfPresent(Key key, Object version)
Removes the value associated with the given key, if it matches the expected version.
-
-
-
Method Detail
-
computeIfAbsent
Value computeIfAbsent(Key key, Object version, ISerializableThrowingFunction<? super Key,? extends Value> loader) throws IOException
Gets the value associated with the given key. If no value exists yet, or if it exists but does not match the given value, it will be loaded using the given loader.- Parameters:
key
- The key for which to get a value.version
- The version of the key.loader
- The loader to use if the value does not exist or is stale.- Returns:
- The associated value, either from the store or obtained from the given loader.
- Throws:
IOException
- If the loader throws an exception.
-
getIfPresent
Value getIfPresent(Key key, Object version)
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), it will be removed.- Parameters:
key
- The key to get the value for.version
- The version of the key.- Returns:
- The associated value, if present and up-to-date, or null if no value exists or does not match the version.
-
remove
void remove(Key key)
Removes the associated value form this store. Does nothing if no value exists yet.- Parameters:
key
- The descriptor of the file to remove the derivative for.
-
removeAndGetIfPresent
Value removeAndGetIfPresent(Key key, Object version)
Removes the value associated with the given key, if it matches the expected version. 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.version
- The version of the key.- Returns:
- The associated value, if present and up-to-date, or null if no value exists or does not match the version.
-
-