Package org.exoplatform.services.cache
Interface ExoCache<K extends Serializable,V>
- All Known Implementing Classes:
AsyncInvalidationExoCache,ConcurrentFIFOExoCache,FIFOExoCache,InvalidationExoCache,SimpleExoCache
public interface ExoCache<K extends Serializable,V>
Created by The eXo Platform SAS
A bare cache.
A bare cache.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheListener(CacheListener<? super K, ? super V> listener) Add a listener.voidClears the cache.get(Serializable key) Performs a lookup operation.Returns a list of cached object that are considered as valid when the method is called.intReturns the number of time the cache was queried and a valid entry was returned.intReturns the number of time the cache was queried and no entry was returned.intReturns the number of entries in the cache.getLabel()Returns the cache labellongReturns the maximum life time of an entry in the cache.intReturns the maximum capacity of the cache.getName()Returns the cache namebooleandefault voidon clear cache eventdefault voidOn expire entry eventdefault voidOn get entry eventdefault voidOn put entry eventdefault voidonPutLocal(K key, V obj) On put entry eventdefault voidOn remove entry eventvoidPerforms a put in the cache.default voidputAsyncMap(Map<? extends K, ? extends V> objs) Performs a put of all the entries provided by the map argument on asynchronous mode.default voidPerforms a put in the cache local mode (avoid replication).voidPerforms a put of all the entries provided by the map argument.remove(Serializable key) Removes an entry from the cache.Clears the cache and returns the list of cached object that are considered as valid when the method is called.default voidremoveLocal(Serializable key) Removes an entry from the cache local mode (avoid replication).voidselect(CachedObjectSelector<? super K, ? super V> selector) Selects a subset of the cache.voidSets the cache labelvoidsetLiveTime(long period) Sets the maximum life time of an entry in the cache.voidsetLogEnabled(boolean b) voidsetMaxSize(int max) Sets the maximum capacity of the cache.voidSets the cache name.
-
Method Details
-
getName
String getName()Returns the cache name- Returns:
- the cache name
-
setName
Sets the cache name.- Parameters:
name- the cache name
-
getLabel
String getLabel()Returns the cache label- Returns:
- the cache label
-
setLabel
Sets the cache label- Parameters:
s- the cache label
-
get
Performs a lookup operation.- Parameters:
key- the cache key- Returns:
- the cached value which may be evaluated to null
-
remove
Removes an entry from the cache.- Parameters:
key- the cache key- Returns:
- the previously cached value or null if no entry existed or that entry value was evaluated to null
- Throws:
NullPointerException- if the provided key is null
-
removeLocal
Removes an entry from the cache local mode (avoid replication).- Parameters:
key- the cache key- Throws:
NullPointerException- if the provided key is null
-
put
Performs a put in the cache.- Parameters:
key- the cache keyvalue- the cached value- Throws:
NullPointerException- if the key is null
-
putLocal
Performs a put in the cache local mode (avoid replication).- Parameters:
key- the cache keyvalue- the cached value- Throws:
NullPointerException- if the key is null
-
putMap
void putMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentExceptionPerforms a put of all the entries provided by the map argument.- Parameters:
objs- the objects to put- Throws:
NullPointerException- if the provided argument is nullIllegalArgumentException- if the provided map contains a null key
-
putAsyncMap
default void putAsyncMap(Map<? extends K, ? extends V> objs) throws NullPointerException, IllegalArgumentExceptionPerforms a put of all the entries provided by the map argument on asynchronous mode.- Parameters:
objs- the objects to put- Throws:
NullPointerException- if the provided argument is nullIllegalArgumentException- if the provided map contains a null keyUnsupportedOperationException- if async put operation is not supported
-
clearCache
void clearCache()Clears the cache. -
select
Selects a subset of the cache.- Parameters:
selector- the selector- Throws:
Exception- any exception
-
getCacheSize
int getCacheSize()Returns the number of entries in the cache.- Returns:
- the size of the cache
-
getMaxSize
int getMaxSize()Returns the maximum capacity of the cache.- Returns:
- the maximum capacity
-
setMaxSize
void setMaxSize(int max) Sets the maximum capacity of the cache.- Parameters:
max- the maximum capacity
-
getLiveTime
long getLiveTime()Returns the maximum life time of an entry in the cache. The life time is a value in seconds, a negative value means that the life time is infinite.- Returns:
- the live time
-
setLiveTime
void setLiveTime(long period) Sets the maximum life time of an entry in the cache.- Parameters:
period- the live time
-
getCacheHit
int getCacheHit()Returns the number of time the cache was queried and a valid entry was returned.- Returns:
- the cache hits
-
getCacheMiss
int getCacheMiss()Returns the number of time the cache was queried and no entry was returned.- Returns:
- the cache misses
-
getCachedObjects
Returns a list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.- Returns:
- the list of cached objects
- Throws:
Exception- any exception
-
removeCachedObjects
Clears the cache and returns the list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.- Returns:
- the list of cached objects
-
addCacheListener
Add a listener.- Parameters:
listener- the listener to add- Throws:
NullPointerException- if the listener is null
-
onGet
On get entry event- Parameters:
key- entry keyobj- value
-
onExpire
On expire entry event- Parameters:
key- entry keyobj- value
-
onRemove
On remove entry event- Parameters:
key- entry keyobj- value
-
onPut
On put entry event- Parameters:
key- entry keyobj- value
-
onPutLocal
On put entry event- Parameters:
key- entry keyobj- value
-
onClearCache
default void onClearCache()on clear cache event -
isLogEnabled
boolean isLogEnabled() -
setLogEnabled
void setLogEnabled(boolean b)
-