org.exoplatform.services.cache.concurrent
Class ConcurrentFIFOExoCache

java.lang.Object
  extended by org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache
All Implemented Interfaces:
ExoCache

public class ConcurrentFIFOExoCache
extends java.lang.Object
implements ExoCache

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, org.apache.commons.logging.Log log)
           
ConcurrentFIFOExoCache(org.apache.commons.logging.Log log)
           
ConcurrentFIFOExoCache(java.lang.String name, int maxSize)
           
ConcurrentFIFOExoCache(java.lang.String name, int maxSize, org.apache.commons.logging.Log log)
           
 
Method Summary
 void addCacheListener(CacheListener listener)
           
 void assertConsistent()
           
 void clearCache()
          Clears the cache.
 java.lang.Object get(java.io.Serializable name)
          Performs a lookup operation.
 java.util.List getCachedObjects()
          Returns a list of cached object that are considered as valid when the method is called.
 int getCacheHit()
           
 int getCacheMiss()
           
 int getCacheSize()
           
 java.lang.String getLabel()
           
 long getLiveTime()
           
 long getLiveTimeMillis()
           
 int getMaxSize()
           
 java.lang.String getName()
           
 boolean isDistributed()
           
 boolean isLogEnabled()
           
 boolean isReplicated()
           
 void put(java.io.Serializable name, java.lang.Object obj)
          Performs a put in the cache.
 void putMap(java.util.Map<java.io.Serializable,java.lang.Object> objs)
          Performs a put of all the entries provided by the map argument.
 java.lang.Object remove(java.io.Serializable name)
          Removes an entry from the cache.
 java.util.List removeCachedObjects()
          Clears the cache and returns the list of cached object that are considered as valid when the method is called.
 void select(CachedObjectSelector selector)
          Selects a subset of the cache.
 void setDistributed(boolean distributed)
           
 void setLabel(java.lang.String name)
           
 void setLiveTime(long period)
           
 void setLiveTimeMillis(long liveTimeMillis)
           
 void setLogEnabled(boolean logEnabled)
           
 void setMaxSize(int max)
           
 void setName(java.lang.String s)
           
 void setReplicated(boolean replicated)
           
 
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(org.apache.commons.logging.Log log)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(int maxSize)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(int maxSize,
                              org.apache.commons.logging.Log log)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(java.lang.String name,
                              int maxSize)

ConcurrentFIFOExoCache

public ConcurrentFIFOExoCache(java.lang.String name,
                              int maxSize,
                              org.apache.commons.logging.Log log)
Method Detail

assertConsistent

public void assertConsistent()

getName

public java.lang.String getName()
Specified by:
getName in interface ExoCache

setName

public void setName(java.lang.String s)
Specified by:
setName in interface ExoCache

getLabel

public java.lang.String getLabel()
Specified by:
getLabel in interface ExoCache

setLabel

public void setLabel(java.lang.String name)
Specified by:
setLabel in interface ExoCache

getLiveTime

public long getLiveTime()
Specified by:
getLiveTime in interface ExoCache

setLiveTime

public void setLiveTime(long period)
Specified by:
setLiveTime in interface ExoCache

getLiveTimeMillis

public long getLiveTimeMillis()

setLiveTimeMillis

public void setLiveTimeMillis(long liveTimeMillis)

getMaxSize

public int getMaxSize()
Specified by:
getMaxSize in interface ExoCache

setMaxSize

public void setMaxSize(int max)
Specified by:
setMaxSize in interface ExoCache

get

public java.lang.Object get(java.io.Serializable name)
Description copied from interface: ExoCache
Performs a lookup operation.

Specified by:
get in interface ExoCache
Parameters:
name - the cache key
Returns:
the cached value which may be evaluated to null

put

public void put(java.io.Serializable name,
                java.lang.Object obj)
Description copied from interface: ExoCache
Performs a put in the cache.

Specified by:
put in interface ExoCache
Parameters:
name - the cache key
obj - the cached value

putMap

public void putMap(java.util.Map<java.io.Serializable,java.lang.Object> objs)
Description copied from interface: ExoCache
Performs a put of all the entries provided by the map argument.

Specified by:
putMap in interface ExoCache
Parameters:
objs - the objects to put

remove

public java.lang.Object remove(java.io.Serializable name)
Description copied from interface: ExoCache
Removes an entry from the cache.

Specified by:
remove in interface ExoCache
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 java.util.List 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
Returns:
the list of cached objects

removeCachedObjects

public java.util.List removeCachedObjects()
                                   throws java.lang.Exception
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
Returns:
the list of cached objects
Throws:
java.lang.Exception - any exception

clearCache

public void clearCache()
                throws java.lang.Exception
Description copied from interface: ExoCache
Clears the cache.

Specified by:
clearCache in interface ExoCache
Throws:
java.lang.Exception - any exception

select

public void select(CachedObjectSelector selector)
            throws java.lang.Exception
Description copied from interface: ExoCache
Selects a subset of the cache.

Specified by:
select in interface ExoCache
Parameters:
selector - the selector
Throws:
java.lang.Exception - any exception

getCacheSize

public int getCacheSize()
Specified by:
getCacheSize in interface ExoCache

getCacheHit

public int getCacheHit()
Specified by:
getCacheHit in interface ExoCache

getCacheMiss

public int getCacheMiss()
Specified by:
getCacheMiss in interface ExoCache

addCacheListener

public void addCacheListener(CacheListener listener)
Specified by:
addCacheListener in interface ExoCache

isDistributed

public boolean isDistributed()
Specified by:
isDistributed in interface ExoCache

setDistributed

public void setDistributed(boolean distributed)
Specified by:
setDistributed in interface ExoCache

isReplicated

public boolean isReplicated()
Specified by:
isReplicated in interface ExoCache

setReplicated

public void setReplicated(boolean replicated)
Specified by:
setReplicated in interface ExoCache

isLogEnabled

public boolean isLogEnabled()
Specified by:
isLogEnabled in interface ExoCache

setLogEnabled

public void setLogEnabled(boolean logEnabled)
Specified by:
setLogEnabled in interface ExoCache


Copyright © 2012 eXo Platform SAS. All Rights Reserved.