public abstract class Cache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static CacheImpl |
cacheImpl
The underlying cache implementation
|
static CacheImpl |
forcedCacheImpl
Sometime we REALLY need to change the implementation :)
|
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
static void |
add(java.lang.String key,
java.lang.Object value)
Add an element only if it doesn't exist and store it indefinitely.
|
static void |
add(java.lang.String key,
java.lang.Object value,
java.lang.String expiration)
Add an element only if it doesn't exist.
|
static void |
clear()
Clear all data from cache.
|
static long |
decr(java.lang.String key)
Decrement the element value (must be a Number) by 1.
|
static long |
decr(java.lang.String key,
int by)
Decrement the element value (must be a Number).
|
static void |
delete(java.lang.String key)
Delete an element from the cache.
|
static java.util.Map<java.lang.String,java.lang.Object> |
get(java.lang.String... key)
Bulk retrieve.
|
static java.lang.Object |
get(java.lang.String key)
Retrieve an object.
|
static <T> T |
get(java.lang.String key,
java.lang.Class<T> clazz)
Convenient clazz to get a value a class type;
|
static long |
incr(java.lang.String key)
Increment the element value (must be a Number) by 1.
|
static long |
incr(java.lang.String key,
int by)
Increment the element value (must be a Number).
|
static void |
init()
Initialize the cache system.
|
static void |
replace(java.lang.String key,
java.lang.Object value)
Replace an element only if it already exists and store it indefinitely.
|
static void |
replace(java.lang.String key,
java.lang.Object value,
java.lang.String expiration)
Replace an element only if it already exists.
|
static boolean |
safeAdd(java.lang.String key,
java.lang.Object value,
java.lang.String expiration)
Add an element only if it doesn't exist, and return only when
the element is effectively cached.
|
static boolean |
safeDelete(java.lang.String key)
Delete an element from the cache and return only when the
element is effectively removed.
|
static boolean |
safeReplace(java.lang.String key,
java.lang.Object value,
java.lang.String expiration)
Replace an element only if it already exists and return only when the
element is effectively cached.
|
static boolean |
safeSet(java.lang.String key,
java.lang.Object value,
java.lang.String expiration)
Set an element and return only when the element is effectively cached.
|
static void |
set(java.lang.String key,
java.lang.Object value)
Set an element and store it indefinitely.
|
static void |
set(java.lang.String key,
java.lang.Object value,
java.lang.String expiration)
Set an element.
|
static void |
stop()
Stop the cache system.
|
public static CacheImpl cacheImpl
public static CacheImpl forcedCacheImpl
public static void add(java.lang.String key, java.lang.Object value, java.lang.String expiration)
key
- Element keyvalue
- Element valueexpiration
- Ex: 10s, 3mn, 8hpublic static boolean safeAdd(java.lang.String key, java.lang.Object value, java.lang.String expiration)
key
- Element keyvalue
- Element valueexpiration
- Ex: 10s, 3mn, 8hpublic static void add(java.lang.String key, java.lang.Object value)
key
- Element keyvalue
- Element valuepublic static void set(java.lang.String key, java.lang.Object value, java.lang.String expiration)
key
- Element keyvalue
- Element valueexpiration
- Ex: 10s, 3mn, 8hpublic static boolean safeSet(java.lang.String key, java.lang.Object value, java.lang.String expiration)
key
- Element keyvalue
- Element valueexpiration
- Ex: 10s, 3mn, 8hpublic static void set(java.lang.String key, java.lang.Object value)
key
- Element keyvalue
- Element valuepublic static void replace(java.lang.String key, java.lang.Object value, java.lang.String expiration)
key
- Element keyvalue
- Element valueexpiration
- Ex: 10s, 3mn, 8hpublic static boolean safeReplace(java.lang.String key, java.lang.Object value, java.lang.String expiration)
key
- Element keyvalue
- Element valueexpiration
- Ex: 10s, 3mn, 8hpublic static void replace(java.lang.String key, java.lang.Object value)
key
- Element keyvalue
- Element valuepublic static long incr(java.lang.String key, int by)
key
- Element keyby
- The incr valuepublic static long incr(java.lang.String key)
key
- Element keypublic static long decr(java.lang.String key, int by)
key
- Element keyby
- The decr valuepublic static long decr(java.lang.String key)
key
- Element keypublic static java.lang.Object get(java.lang.String key)
key
- The element keypublic static java.util.Map<java.lang.String,java.lang.Object> get(java.lang.String... key)
key
- List of keyspublic static void delete(java.lang.String key)
key
- The element keypublic static boolean safeDelete(java.lang.String key)
key
- The element keypublic static void clear()
public static <T> T get(java.lang.String key, java.lang.Class<T> clazz)
T
- The needed typekey
- The element keyclazz
- The type classpublic static void init()
public static void stop()
Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly