eXo Kernel :: Component :: Cache Service 2.4.8-GA

org.exoplatform.services.cache.concurrent
Class ConcurrentFIFOExoCache<K extends Serializable,V>

java.lang.Object
  extended by org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache<K,V>
All Implemented Interfaces:
ExoCache<K,V>
Direct Known Subclasses:
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.

Version:
$Revision$
Author:
Julien Viet

Constructor Summary
ConcurrentFIFOExoCache()
           
ConcurrentFIFOExoCache(int maxSize)
           
ConcurrentFIFOExoCache(int maxSize, Log log)
           
ConcurrentFIFOExoCache(Log log)
           
ConcurrentFIFOExoCache(String name, int maxSize)
           
ConcurrentFIFOExoCache(String name, int maxSize, Log log)
           
 
Method Summary
 void addCacheListener(CacheListener<? super K,? super V> listener)
          Add a listener.
 void assertConsistent()
           
 void clearCache()
          Clears the cache.
 V get(Serializable name)
          Performs a lookup operation.
 List<? extends V> getCachedObjects()
          Returns a list of cached object that are considered as valid when the method is called.
 int getCacheHit()
          Returns the number of time the cache was queried and a valid entry was returned.
 int getCacheMiss()
          Returns the number of time the cache was queried and no entry was returned.
 int getCacheSize()
          Returns the number of entries in the cache.
 String getLabel()
          Returns the cache label
 long getLiveTime()
          Returns the maximum life time of an entry in the cache.
 long getLiveTimeMillis()
           
 int getMaxSize()
          Returns the maximum capacity of the cache.
 String getName()
          Returns the cache name
 boolean isLogEnabled()
           
 void put(K name, V obj)
          Performs a put in the cache.
 void putMap(Map<? extends K,? extends V> objs)
          Performs a put of all the entries provided by the map argument.
 V remove(Serializable name)
          Removes an entry from the cache.
 List<? extends V> removeCachedObjects()
          Clears the cache and returns the list of cached object that are considered as valid when the method is called.
 void select(CachedObjectSelector<? super K,? super V> selector)
          Selects a subset of the cache.
 void setLabel(String name)
          Sets the cache label
 void setLiveTime(long period)
          Sets the maximum life time of an entry in the cache.
 void setLiveTimeMillis(long liveTimeMillis)
           
 void setLogEnabled(boolean logEnabled)
           
 void setMaxSize(int max)
          Sets the maximum capacity of the cache.
 void setName(String s)
          Sets the cache name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache()

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(Log log)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(int maxSize)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(int maxSize,
                              Log log)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(String name,
                              int maxSize)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(String name,
                              int maxSize,
                              Log log)
Method Detail

assertConsistent

public void assertConsistent()

getName

public String getName()
Description copied from interface: ExoCache
Returns the cache name

Specified by:
getName in interface ExoCache<K extends Serializable,V>
Returns:
the cache name

setName

public void setName(String s)
Description copied from interface: ExoCache
Sets the cache name.

Specified by:
setName in interface ExoCache<K extends Serializable,V>
Parameters:
s - the cache name

getLabel

public String getLabel()
Description copied from interface: ExoCache
Returns the cache label

Specified by:
getLabel in interface ExoCache<K extends Serializable,V>
Returns:
the cache label

setLabel

public void setLabel(String name)
Description copied from interface: ExoCache
Sets the cache label

Specified by:
setLabel in interface ExoCache<K extends Serializable,V>
Parameters:
name - the cache label

getLiveTime

public long getLiveTime()
Description copied from interface: ExoCache
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.

Specified by:
getLiveTime in interface ExoCache<K extends Serializable,V>
Returns:
the live time

setLiveTime

public void setLiveTime(long period)
Description copied from interface: ExoCache
Sets the maximum life time of an entry in the cache.

Specified by:
setLiveTime in interface ExoCache<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: ExoCache
Returns the maximum capacity of the cache.

Specified by:
getMaxSize in interface ExoCache<K extends Serializable,V>
Returns:
the maximum capacity

setMaxSize

public void setMaxSize(int max)
Description copied from interface: ExoCache
Sets the maximum capacity of the cache.

Specified by:
setMaxSize in interface ExoCache<K extends Serializable,V>
Parameters:
max - the maximum capacity

get

public V get(Serializable name)
Description copied from interface: ExoCache
Performs a lookup operation.

Specified by:
get in interface ExoCache<K extends Serializable,V>
Parameters:
name - the cache key
Returns:
the cached value which may be evaluated to null

put

public void put(K name,
                V obj)
Description copied from interface: ExoCache
Performs a put in the cache.

Specified by:
put in interface ExoCache<K extends Serializable,V>
Parameters:
name - the cache key
obj - the cached value

putMap

public void putMap(Map<? extends K,? extends V> objs)
Description copied from interface: ExoCache
Performs a put of all the entries provided by the map argument.

Specified by:
putMap in interface ExoCache<K extends Serializable,V>
Parameters:
objs - the objects to put

remove

public V remove(Serializable name)
Description copied from interface: ExoCache
Removes an entry from the cache.

Specified by:
remove in interface ExoCache<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

public List<? extends V> getCachedObjects()
Description copied from interface: ExoCache
Returns a list of cached object that are considered as valid when the method is called. Any non valid object will not be returnted.

Specified by:
getCachedObjects in interface ExoCache<K extends Serializable,V>
Returns:
the list of cached objects

removeCachedObjects

public List<? extends V> removeCachedObjects()
Description copied from interface: ExoCache
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.

Specified by:
removeCachedObjects in interface ExoCache<K extends Serializable,V>
Returns:
the list of cached objects

clearCache

public void clearCache()
Description copied from interface: ExoCache
Clears the cache.

Specified by:
clearCache in interface ExoCache<K extends Serializable,V>

select

public void select(CachedObjectSelector<? super K,? super V> selector)
            throws Exception
Description copied from interface: ExoCache
Selects a subset of the cache.

Specified by:
select in interface ExoCache<K extends Serializable,V>
Parameters:
selector - the selector
Throws:
Exception - any exception

getCacheSize

public int getCacheSize()
Description copied from interface: ExoCache
Returns the number of entries in the cache.

Specified by:
getCacheSize in interface ExoCache<K extends Serializable,V>
Returns:
the size of the cache

getCacheHit

public int getCacheHit()
Description copied from interface: ExoCache
Returns the number of time the cache was queried and a valid entry was returned.

Specified by:
getCacheHit in interface ExoCache<K extends Serializable,V>
Returns:
the cache hits

getCacheMiss

public int getCacheMiss()
Description copied from interface: ExoCache
Returns the number of time the cache was queried and no entry was returned.

Specified by:
getCacheMiss in interface ExoCache<K extends Serializable,V>
Returns:
the cache misses

addCacheListener

public void addCacheListener(CacheListener<? super K,? super V> listener)
Description copied from interface: ExoCache
Add a listener.

Specified by:
addCacheListener in interface ExoCache<K extends Serializable,V>
Parameters:
listener - the listener to add

isLogEnabled

public boolean isLogEnabled()
Specified by:
isLogEnabled in interface ExoCache<K extends Serializable,V>

setLogEnabled

public void setLogEnabled(boolean logEnabled)
Specified by:
setLogEnabled in interface ExoCache<K extends Serializable,V>

eXo Kernel :: Component :: Cache Service 2.4.8-GA

Copyright © 2014 eXo Platform SAS. All Rights Reserved.