Interface CachedDataManager.Container<T extends CachedData>
- Type Parameters:
T- the data type
- Enclosing interface:
- CachedDataManager
cached data within
a CachedDataManager instance.-
Method Summary
Modifier and TypeMethodDescriptioncalculate(@NonNull QueryOptions queryOptions) Calculatesdata, bypassing the cache.get(@NonNull QueryOptions queryOptions) Getsdatafrom the cache.voidInvalidates all cached data instances.voidinvalidate(@NonNull QueryOptions queryOptions) Invalidates any cached data instances mapped to the given context.voidRecalculates data for all known contexts.voidrecalculate(@NonNull QueryOptions queryOptions) (Re)calculates data for a given context.reload()Reloads permission data for all known contexts.@NonNull CompletableFuture<? extends T>reload(@NonNull QueryOptions queryOptions) (Re)loads permission data for a given context.
-
Method Details
-
get
Getsdatafrom the cache.- Parameters:
queryOptions- the query options- Returns:
- a data instance
- Throws:
NullPointerException- if contexts is null
-
calculate
Calculatesdata, bypassing the cache.The result of this operation is calculated each time the method is called. The result is not added to the internal cache.
It is therefore highly recommended to use
get(QueryOptions)instead.The use cases of this method are more around constructing one-time instances of
data, without adding the result to the cache.- Parameters:
queryOptions- the query options- Returns:
- a data instance
- Throws:
NullPointerException- if contexts is null
-
recalculate
(Re)calculates data for a given context.This method returns immediately in all cases. The (re)calculation is performed asynchronously and applied to the cache in the background.
If there was a previous data instance associated with the given
QueryOptions, then that instance will continue to be returned byget(QueryOptions)until the recalculation is completed.If there was no value calculated and cached prior to the call of this method, then one will be calculated.
- Parameters:
queryOptions- the query options- Throws:
NullPointerException- if contexts is null
-
reload
(Re)loads permission data for a given context.Unlike
recalculate(QueryOptions), this method immediately invalidates any previous data values contained within the cache, and then schedules a task to reload a new data instance to replace the one which was invalidated.The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to
get(QueryOptions)will block until the result of this operation is complete.If there was no value calculated and cached prior to the call of this method, then one will be calculated.
This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
- Parameters:
queryOptions- the query options.- Returns:
- a future
- Throws:
NullPointerException- if contexts is null
-
recalculate
void recalculate()Recalculates data for all known contexts.This method returns immediately. The recalculation is performed asynchronously and applied to the cache in the background.
The previous data instances will continue to be returned by
get(QueryOptions)until the recalculation is completed. -
reload
@NonNull CompletableFuture<Void> reload()Reloads permission data for all known contexts.Unlike
recalculate(), this method immediately invalidates all previous data values contained within the cache, and then schedules a task to reload new data instances to replace the ones which were invalidated.The invalidation happens immediately during the execution of this method. The result of the re-computation encapsulated by the future.
Subsequent calls to
get(QueryOptions)will block until the result of this operation is complete.This method returns a Future so users can optionally choose to wait until the recalculation has been performed.
- Returns:
- a future
-
invalidate
Invalidates any cached data instances mapped to the given context.- Parameters:
queryOptions- the queryOptions to invalidate for
-
invalidate
void invalidate()Invalidates all cached data instances.
-