public enum EhCacheService extends Enum<EhCacheService> implements ICacheService
implement cache service based on EHCACHE
| Enum Constant and Description |
|---|
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
|
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
|
static EhCacheService |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static EhCacheService[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final EhCacheService INSTANCE
public static EhCacheService[] values()
for (EhCacheService c : EhCacheService.values()) System.out.println(c);
public static EhCacheService valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic void put(String key, Serializable value, int ttl)
ICacheServiceStore an item into the cache service by key and set ttl value
put 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)
ICacheServiceStore an item into the cache by key and use default ttl
put in interface ICacheServicepublic Serializable remove(String key)
ICacheServiceRemove an item from cache service by key
remove in interface ICacheServicepublic void evict(String key)
ICacheServiceRemove an item from the cache service by key
evict in interface ICacheServicepublic Serializable get(String key)
ICacheServiceReturn an item from the cache service by key
get in interface ICacheServicepublic boolean contains(String key)
ICacheServiceCheck if the cache contains key
contains in interface ICacheServicepublic void clear()
ICacheServiceRemove all cached items
clear in interface ICacheServicepublic void setDefaultTTL(int ttl)
ICacheServiceSet default ttl value which will be used if user pass 0 as ttl or not specified ttl
setDefaultTTL in interface ICacheServicepublic void shutdown()
ICacheServiceShutdown the cache service
shutdown in interface ICacheServicepublic void startup()
ICacheServiceRestart the cache service after shutdown
Note, by default the cache service should be started after initialized
startup in interface ICacheServiceCopyright © 2017–2021 OSGL (Open Source General Library). All rights reserved.