Package play.cache
Class DefaultAsyncCacheApi
java.lang.Object
play.cache.DefaultAsyncCacheApi
- All Implemented Interfaces:
AsyncCacheApi
Adapts a Scala AsyncCacheApi to a Java AsyncCacheApi. This is Play's default Java AsyncCacheApi
implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> CompletionStage<Optional<T>>Retrieves an object by key.<T> CompletionStage<T>getOrElseUpdate(String key, Callable<CompletionStage<T>> block) Retrieve a value from the cache, or set it from a default Callable function.<T> CompletionStage<T>getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration) Retrieve a value from the cache, or set it from a default Callable function.Removes a value from the cache.Removes all values from the cache.Sets a value without expiration.Sets a value with expiration.sync()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface play.cache.AsyncCacheApi
getOptional
-
Constructor Details
-
DefaultAsyncCacheApi
@Inject public DefaultAsyncCacheApi(play.api.cache.AsyncCacheApi cacheApi)
-
-
Method Details
-
sync
- Specified by:
syncin interfaceAsyncCacheApi- Returns:
- a synchronous version of this cache, which can be used to make synchronous calls.
-
get
Description copied from interface:AsyncCacheApiRetrieves an object by key.- Specified by:
getin interfaceAsyncCacheApi- Type Parameters:
T- the type of the stored object- Parameters:
key- the key to look up- Returns:
- a CompletionStage containing the value wrapped in an Optional
-
getOrElseUpdate
public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration) Description copied from interface:AsyncCacheApiRetrieve a value from the cache, or set it from a default Callable function.- Specified by:
getOrElseUpdatein interfaceAsyncCacheApi- Type Parameters:
T- the type of the value- Parameters:
key- Item key.block- block returning value to set if key does not existexpiration- expiration period in seconds.- Returns:
- a CompletionStage containing the value
-
getOrElseUpdate
Description copied from interface:AsyncCacheApiRetrieve a value from the cache, or set it from a default Callable function.The value has no expiration.
- Specified by:
getOrElseUpdatein interfaceAsyncCacheApi- Type Parameters:
T- the type of the value- Parameters:
key- Item key.block- block returning value to set if key does not exist- Returns:
- a CompletionStage containing the value
-
set
Description copied from interface:AsyncCacheApiSets a value with expiration.- Specified by:
setin interfaceAsyncCacheApi- Parameters:
key- Item key.value- The value to set.expiration- expiration in seconds- Returns:
- a CompletionStage containing the value
-
set
Description copied from interface:AsyncCacheApiSets a value without expiration.- Specified by:
setin interfaceAsyncCacheApi- Parameters:
key- Item key.value- The value to set.- Returns:
- a CompletionStage containing the value
-
remove
Description copied from interface:AsyncCacheApiRemoves a value from the cache.- Specified by:
removein interfaceAsyncCacheApi- Parameters:
key- The key to remove the value for.- Returns:
- a CompletionStage containing the value
-
removeAll
Description copied from interface:AsyncCacheApiRemoves all values from the cache. This may be useful as an admin user operation if it is supported by your cache.- Specified by:
removeAllin interfaceAsyncCacheApi- Returns:
- a CompletionStage containing either a Done when successful or an exception when unsuccessful.
-