public class SyncCacheApiAdapter extends Object implements SyncCacheApi
Constructor and Description |
---|
SyncCacheApiAdapter(play.api.cache.SyncCacheApi scalaApi) |
Modifier and Type | Method and Description |
---|---|
<T> Optional<T> |
get(String key)
Retrieves an object by key.
|
<T> T |
getOrElseUpdate(String key,
Callable<T> block)
Retrieve a value from the cache, or set it from a default Callable function.
|
<T> T |
getOrElseUpdate(String key,
Callable<T> block,
int expiration)
Retrieve a value from the cache, or set it from a default Callable function.
|
void |
remove(String key)
Removes a value from the cache.
|
void |
set(String key,
Object value)
Sets a value without expiration.
|
void |
set(String key,
Object value,
int expiration)
Sets a value with expiration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getOptional
public SyncCacheApiAdapter(play.api.cache.SyncCacheApi scalaApi)
public <T> Optional<T> get(String key)
SyncCacheApi
get
in interface SyncCacheApi
T
- the type of the stored objectkey
- the key to look uppublic <T> T getOrElseUpdate(String key, Callable<T> block, int expiration)
SyncCacheApi
getOrElseUpdate
in interface SyncCacheApi
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> T getOrElseUpdate(String key, Callable<T> block)
SyncCacheApi
The value has no expiration.
getOrElseUpdate
in interface SyncCacheApi
T
- the type of the valuekey
- Item key.block
- block returning value to set if key does not existpublic void set(String key, Object value, int expiration)
SyncCacheApi
set
in interface SyncCacheApi
key
- Item key.value
- The value to set.expiration
- expiration in secondspublic void set(String key, Object value)
SyncCacheApi
set
in interface SyncCacheApi
key
- Item key.value
- The value to set.public void remove(String key)
SyncCacheApi
remove
in interface SyncCacheApi
key
- The key to remove the value for.