public interface CacheService
Modifier and Type | Field and Description |
---|---|
static String |
DEF_CACHE_NAME |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all cached items
|
void |
evict(String key)
Remove an item from the cache service by key
|
<T> T |
get(String key)
Return an item from the cache service by key
|
void |
put(String key,
Object value)
Store an item into the cache by key and use default ttl
|
void |
put(String key,
Object value,
int ttl)
Store an item into the cache service by key and set ttl value
|
void |
setDefaultTTL(int ttl)
Set default ttl value which will be used if user pass 0 as ttl or not specified ttl
Note some service might not favor this method after the internal cache service
is initialized.
|
void |
shutdown()
Shutdown the cache service
|
void |
startup()
Restart the cache service after shutdown
|
static final String DEF_CACHE_NAME
void put(String key, Object value, int ttl)
key
- the cache keyvalue
- the object to be cachedttl
- time to live of the cached item. Time unit is second.
If set to negative number, then it will never expire.
If set to zero then the default ttl value will be usedvoid put(String key, Object value)
key
- the cache keyvalue
- the object to be cachedvoid evict(String key)
key
- the cache key<T> T get(String key)
T
- the generic type of the return valuekey
- the cache keyvoid clear()
void setDefaultTTL(int ttl)
ttl
- the default ttl value in secondsvoid shutdown()
void startup()
Note, by default the cache service should be started after initialized
Copyright © 2017. All Rights Reserved.