Class ConcurrentFIFOExoCache<K extends Serializable,V>
java.lang.Object
org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache<K,V>
- All Implemented Interfaces:
ExoCache<K,V>
- Direct Known Subclasses:
AsyncInvalidationExoCache,FIFOExoCache,SimpleExoCache
public class ConcurrentFIFOExoCache<K extends Serializable,V>
extends Object
implements ExoCache<K,V>
An
ExoCache implementation based on ConcurrentHashMap
that minimize locking. Cache entries are maintained in a fifo list that is used for the fifo eviction policy.-
Constructor Summary
ConstructorsConstructorDescriptionConcurrentFIFOExoCache(int maxSize) ConcurrentFIFOExoCache(int maxSize, org.exoplatform.services.log.Log log) ConcurrentFIFOExoCache(String name, int maxSize) ConcurrentFIFOExoCache(String name, int maxSize, org.exoplatform.services.log.Log log) ConcurrentFIFOExoCache(org.exoplatform.services.log.Log log) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheListener(CacheListener<? super K, ? super V> listener) Add a listener.voidvoidClears the cache.get(Serializable name) 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.longintReturns the maximum capacity of the cache.getName()Returns the cache namebooleanvoidon clear cache eventvoidOn expire entry eventvoidOn get entry eventvoidOn put entry eventvoidonPutLocal(K key, V obj) On put entry eventvoidOn remove entry eventvoidPerforms a put in the cache.voidPerforms a put in the cache local mode (avoid replication).voidPerforms a put of all the entries provided by the map argument.remove(Serializable name) 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.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.voidsetLiveTimeMillis(long liveTimeMillis) voidsetLogEnabled(boolean logEnabled) voidsetMaxSize(int max) Sets the maximum capacity of the cache.voidSets the cache name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.exoplatform.services.cache.ExoCache
putAsyncMap, removeLocal
-
Constructor Details
-
ConcurrentFIFOExoCache
public ConcurrentFIFOExoCache() -
ConcurrentFIFOExoCache
public ConcurrentFIFOExoCache(org.exoplatform.services.log.Log log) -
ConcurrentFIFOExoCache
public ConcurrentFIFOExoCache(int maxSize) -
ConcurrentFIFOExoCache
public ConcurrentFIFOExoCache(int maxSize, org.exoplatform.services.log.Log log) -
ConcurrentFIFOExoCache
-
ConcurrentFIFOExoCache
-
-
Method Details
-
assertConsistent
public void assertConsistent() -
getName
Description copied from interface:ExoCacheReturns the cache name- Specified by:
getNamein interfaceExoCache<K extends Serializable,V> - Returns:
- the cache name
-
setName
Description copied from interface:ExoCacheSets the cache name.- Specified by:
setNamein interfaceExoCache<K extends Serializable,V> - Parameters:
s- the cache name
-
getLabel
Description copied from interface:ExoCacheReturns the cache label- Specified by:
getLabelin interfaceExoCache<K extends Serializable,V> - Returns:
- the cache label
-
setLabel
Description copied from interface:ExoCacheSets the cache label- Specified by:
setLabelin interfaceExoCache<K extends Serializable,V> - Parameters:
name- the cache label
-
getLiveTime
public long getLiveTime()Description copied from interface:ExoCacheReturns 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.- Specified by:
getLiveTimein interfaceExoCache<K extends Serializable,V> - Returns:
- the live time
-
setLiveTime
public void setLiveTime(long period) Description copied from interface:ExoCacheSets the maximum life time of an entry in the cache.- Specified by:
setLiveTimein interfaceExoCache<K extends Serializable,V> - Parameters:
period- the live time
-
getLiveTimeMillis
public long getLiveTimeMillis() -
setLiveTimeMillis
public void setLiveTimeMillis(long liveTimeMillis) -
getMaxSize
public int getMaxSize()Description copied from interface:ExoCacheReturns the maximum capacity of the cache.- Specified by:
getMaxSizein interfaceExoCache<K extends Serializable,V> - Returns:
- the maximum capacity
-
setMaxSize
public void setMaxSize(int max) Description copied from interface:ExoCacheSets the maximum capacity of the cache.- Specified by:
setMaxSizein interfaceExoCache<K extends Serializable,V> - Parameters:
max- the maximum capacity
-
get
Description copied from interface:ExoCachePerforms a lookup operation.- Specified by:
getin interfaceExoCache<K extends Serializable,V> - Parameters:
name- the cache key- Returns:
- the cached value which may be evaluated to null
-
put
Description copied from interface:ExoCachePerforms a put in the cache.- Specified by:
putin interfaceExoCache<K extends Serializable,V> - Parameters:
name- the cache keyobj- the cached value
-
putLocal
Description copied from interface:ExoCachePerforms a put in the cache local mode (avoid replication).- Specified by:
putLocalin interfaceExoCache<K extends Serializable,V> - Parameters:
name- the cache keyobj- the cached value
-
putMap
Description copied from interface:ExoCachePerforms a put of all the entries provided by the map argument.- Specified by:
putMapin interfaceExoCache<K extends Serializable,V> - Parameters:
objs- the objects to put
-
remove
Description copied from interface:ExoCacheRemoves an entry from the cache.- Specified by:
removein interfaceExoCache<K extends Serializable,V> - Parameters:
name- the cache key- Returns:
- the previously cached value or null if no entry existed or that entry value was evaluated to null
-
getCachedObjects
Description copied from interface:ExoCacheReturns a list of cached object that are considered as valid when the method is called. Any non valid object will not be returned.- Specified by:
getCachedObjectsin interfaceExoCache<K extends Serializable,V> - Returns:
- the list of cached objects
-
removeCachedObjects
Description copied from interface:ExoCacheClears 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.- Specified by:
removeCachedObjectsin interfaceExoCache<K extends Serializable,V> - Returns:
- the list of cached objects
-
clearCache
public void clearCache()Description copied from interface:ExoCacheClears the cache.- Specified by:
clearCachein interfaceExoCache<K extends Serializable,V>
-
select
Description copied from interface:ExoCacheSelects a subset of the cache. -
getCacheSize
public int getCacheSize()Description copied from interface:ExoCacheReturns the number of entries in the cache.- Specified by:
getCacheSizein interfaceExoCache<K extends Serializable,V> - Returns:
- the size of the cache
-
getCacheHit
public int getCacheHit()Description copied from interface:ExoCacheReturns the number of time the cache was queried and a valid entry was returned.- Specified by:
getCacheHitin interfaceExoCache<K extends Serializable,V> - Returns:
- the cache hits
-
getCacheMiss
public int getCacheMiss()Description copied from interface:ExoCacheReturns the number of time the cache was queried and no entry was returned.- Specified by:
getCacheMissin interfaceExoCache<K extends Serializable,V> - Returns:
- the cache misses
-
addCacheListener
Description copied from interface:ExoCacheAdd a listener.- Specified by:
addCacheListenerin interfaceExoCache<K extends Serializable,V> - Parameters:
listener- the listener to add
-
isLogEnabled
public boolean isLogEnabled()- Specified by:
isLogEnabledin interfaceExoCache<K extends Serializable,V>
-
setLogEnabled
public void setLogEnabled(boolean logEnabled) - Specified by:
setLogEnabledin interfaceExoCache<K extends Serializable,V>
-
onExpire
Description copied from interface:ExoCacheOn expire entry event- Specified by:
onExpirein interfaceExoCache<K extends Serializable,V> - Parameters:
key- entry keyobj- value
-
onRemove
Description copied from interface:ExoCacheOn remove entry event- Specified by:
onRemovein interfaceExoCache<K extends Serializable,V> - Parameters:
key- entry keyobj- value
-
onPut
Description copied from interface:ExoCacheOn put entry event- Specified by:
onPutin interfaceExoCache<K extends Serializable,V> - Parameters:
key- entry keyobj- value
-
onPutLocal
Description copied from interface:ExoCacheOn put entry event- Specified by:
onPutLocalin interfaceExoCache<K extends Serializable,V> - Parameters:
key- entry keyobj- value
-
onGet
Description copied from interface:ExoCacheOn get entry event- Specified by:
onGetin interfaceExoCache<K extends Serializable,V> - Parameters:
key- entry keyobj- value
-
onClearCache
public void onClearCache()Description copied from interface:ExoCacheon clear cache event- Specified by:
onClearCachein interfaceExoCache<K extends Serializable,V>
-
getListeners
-