@Singleton public class DefaultAsyncCacheApi extends Object implements AsyncCacheApi
Constructor and Description |
---|
DefaultAsyncCacheApi(play.api.cache.AsyncCacheApi cacheApi) |
Modifier and Type | Method and Description |
---|---|
<T> CompletionStage<Optional<T>> |
get(String key)
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.
|
CompletionStage<akka.Done> |
remove(String key)
Removes a value from the cache.
|
CompletionStage<akka.Done> |
removeAll()
Removes all values from the cache.
|
CompletionStage<akka.Done> |
set(String key,
Object value)
Sets a value without expiration.
|
CompletionStage<akka.Done> |
set(String key,
Object value,
int expiration)
Sets a value with expiration.
|
SyncCacheApi |
sync() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOptional
@Inject public DefaultAsyncCacheApi(play.api.cache.AsyncCacheApi cacheApi)
public SyncCacheApi sync()
sync
in interface AsyncCacheApi
public <T> CompletionStage<Optional<T>> get(String key)
AsyncCacheApi
get
in interface AsyncCacheApi
T
- the type of the stored objectkey
- the key to look uppublic <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration)
AsyncCacheApi
getOrElseUpdate
in interface AsyncCacheApi
T
- the type of the valuekey
- Item key.block
- block returning value to set if key does not existexpiration
- expiration period in seconds.public <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block)
AsyncCacheApi
The value has no expiration.
getOrElseUpdate
in interface AsyncCacheApi
T
- the type of the valuekey
- Item key.block
- block returning value to set if key does not existpublic CompletionStage<akka.Done> set(String key, Object value, int expiration)
AsyncCacheApi
set
in interface AsyncCacheApi
key
- Item key.value
- The value to set.expiration
- expiration in secondspublic CompletionStage<akka.Done> set(String key, Object value)
AsyncCacheApi
set
in interface AsyncCacheApi
key
- Item key.value
- The value to set.public CompletionStage<akka.Done> remove(String key)
AsyncCacheApi
remove
in interface AsyncCacheApi
key
- The key to remove the value for.public CompletionStage<akka.Done> removeAll()
AsyncCacheApi
removeAll
in interface AsyncCacheApi