@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<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<Done> |
remove(String key)
Removes a value from the cache.
|
CompletionStage<Done> |
removeAll()
Removes all values from the cache.
|
CompletionStage<Done> |
set(String key,
Object value)
Sets a value without expiration.
|
CompletionStage<Done> |
set(String key,
Object value,
int expiration)
Sets a value with expiration.
|
SyncCacheApi |
sync() |
@Inject public DefaultAsyncCacheApi(play.api.cache.AsyncCacheApi cacheApi)
public SyncCacheApi sync()
sync in interface AsyncCacheApipublic <T> CompletionStage<T> get(String key)
AsyncCacheApiget in interface AsyncCacheApiT - the type of the stored objectkey - the key to look uppublic <T> CompletionStage<T> getOrElseUpdate(String key, Callable<CompletionStage<T>> block, int expiration)
AsyncCacheApigetOrElseUpdate in interface AsyncCacheApiT - 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)
AsyncCacheApigetOrElseUpdate in interface AsyncCacheApiT - the type of the valuekey - Item key.block - block returning value to set if key does not existpublic CompletionStage<Done> set(String key, Object value, int expiration)
AsyncCacheApiset in interface AsyncCacheApikey - Item key.value - The value to set.expiration - expiration in secondspublic CompletionStage<Done> set(String key, Object value)
AsyncCacheApiset in interface AsyncCacheApikey - Item key.value - The value to set.public CompletionStage<Done> remove(String key)
AsyncCacheApiremove in interface AsyncCacheApikey - The key to remove the value for.public CompletionStage<Done> removeAll()
AsyncCacheApiremoveAll in interface AsyncCacheApi