public class Cache
extends java.lang.Object
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
get(java.lang.String key)
Retrieves an object by key.
|
static <T> T |
getOrElse(java.lang.String key,
java.util.concurrent.Callable<T> block,
int expiration)
Retrieve a value from the cache, or set it from a default Callable function.
|
static void |
remove(java.lang.String key)
Removes the entry at a specific key
|
static void |
set(java.lang.String key,
java.lang.Object value)
Sets a value without expiration.
|
static void |
set(java.lang.String key,
java.lang.Object value,
int expiration)
Sets a value with expiration.
|
public static java.lang.Object get(java.lang.String key)
key
- the cache keypublic static <T> T getOrElse(java.lang.String key, java.util.concurrent.Callable<T> block, int expiration)
T
- the type of object being queriedkey
- Item key.block
- block returning value to set if key does not existexpiration
- expiration period in seconds.public static void set(java.lang.String key, java.lang.Object value, int expiration)
key
- the key to setvalue
- the value to setexpiration
- expiration in secondspublic static void set(java.lang.String key, java.lang.Object value)
key
- the key to setvalue
- the value to setpublic static void remove(java.lang.String key)
key
- the key whose entry to remove