public class SimpleCacheService extends Object implements ICacheService
| Modifier and Type | Field and Description |
|---|---|
static SimpleCacheService |
INSTANCE |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Remove all cached items
|
boolean |
contains(String key)
Check if the cache contains key
|
void |
evict(String key)
Remove an item from the cache service by key
|
protected void |
finalize() |
Serializable |
get(String key)
Return an item from the cache service by key
|
void |
put(String key,
Serializable value)
Store an item into the cache by key and use default ttl
|
void |
put(String key,
Serializable value,
int ttl)
Store an item into the cache service by key and set ttl value
|
Serializable |
remove(String key)
Remove an item from cache service by key
|
void |
setDefaultTTL(int ttl)
Set default ttl value which will be used if user pass 0 as ttl or not specified ttl
|
void |
shutdown()
Shutdown the cache service
|
void |
startup()
Restart the cache service after shutdown
|
public static final SimpleCacheService INSTANCE
public void put(String key, Serializable value, int ttl)
ICacheServiceput in interface ICacheServicettl - 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 usedpublic void put(String key, Serializable value)
ICacheServiceput in interface ICacheServicepublic Serializable remove(String key)
ICacheServiceremove in interface ICacheServicepublic void evict(String key)
ICacheServiceevict in interface ICacheServicepublic void clear()
ICacheServiceclear in interface ICacheServicepublic Serializable get(String key)
ICacheServiceget in interface ICacheServicepublic boolean contains(String key)
ICacheServicecontains in interface ICacheServicepublic void setDefaultTTL(int ttl)
ICacheServicesetDefaultTTL in interface ICacheServicepublic void shutdown()
ICacheServiceshutdown in interface ICacheServicepublic void startup()
ICacheServiceNote, by default the cache service should be started after initialized
startup in interface ICacheServiceCopyright © 2015. All Rights Reserved.