T - the data typepublic static interface CachedDataManager.Container<T extends CachedData>
cached data within
a CachedDataManager instance.| Modifier and Type | Method and Description |
|---|---|
T |
calculate(@NonNull QueryOptions queryOptions)
Calculates
data, bypassing the cache. |
T |
get(@NonNull QueryOptions queryOptions)
Gets
data from the cache. |
void |
invalidate()
Invalidates all cached data instances.
|
void |
invalidate(@NonNull QueryOptions queryOptions)
Invalidates any cached data instances mapped to the given context.
|
void |
recalculate()
Recalculates data for all known contexts.
|
void |
recalculate(@NonNull QueryOptions queryOptions)
(Re)calculates data for a given context.
|
@NonNull CompletableFuture<Void> |
reload()
Reloads permission data for all known contexts.
|
@NonNull CompletableFuture<? extends T> |
reload(@NonNull QueryOptions queryOptions)
(Re)loads permission data for a given context.
|
T get(@NonNull QueryOptions queryOptions)
data from the cache.queryOptions - the query optionsNullPointerException - if contexts is nullT calculate(@NonNull QueryOptions queryOptions)
data, 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.
queryOptions - the query optionsNullPointerException - if contexts is nullvoid recalculate(@NonNull QueryOptions queryOptions)
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 by
get(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.
queryOptions - the query optionsNullPointerException - if contexts is null@NonNull CompletableFuture<? extends T> reload(@NonNull QueryOptions queryOptions)
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.
queryOptions - the query options.NullPointerException - if contexts is nullvoid recalculate()
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.
@NonNull CompletableFuture<Void> reload()
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.
void invalidate(@NonNull QueryOptions queryOptions)
queryOptions - the queryOptions to invalidate forvoid invalidate()