public interface SyncCacheApi
Modifier and Type | Method and Description |
---|---|
<T> Optional<T> |
get(String key)
Retrieves an object by key.
|
default <T> Optional<T> |
getOptional(String key)
Deprecated.
Deprecated as of 2.8.0. Renamed to
get(String) . |
<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.
|
<T> Optional<T> get(String key)
T
- the type of the stored objectkey
- the key to look up@Deprecated default <T> Optional<T> getOptional(String key)
get(String)
.T
- the type of the stored objectkey
- the key to look up<T> T getOrElseUpdate(String key, Callable<T> block, int expiration)
T
- the type of the valuekey
- Item key.block
- block returning value to set if key does not existexpiration
- expiration period in seconds.<T> T getOrElseUpdate(String key, Callable<T> block)
The value has no expiration.
T
- the type of the valuekey
- Item key.block
- block returning value to set if key does not existvoid set(String key, Object value, int expiration)
key
- Item key.value
- The value to set.expiration
- expiration in secondsvoid set(String key, Object value)
key
- Item key.value
- The value to set.void remove(String key)
key
- The key to remove the value for.