|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jcs.engine.control.CompositeCache
public class CompositeCache
This is the primary hub for a single cache/region. It controls the flow of items through the cache. The auxiliary and memory caches are plugged in here.
This is the core of a JCS region. Hence, this simple class is the core of JCS.
Field Summary | |
---|---|
static IElementEventQueue |
elementEventQ
EventQueue for handling element events. 1 should be enough for all the regions. |
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType |
---|
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE |
Constructor Summary | |
---|---|
CompositeCache(java.lang.String cacheName,
ICompositeCacheAttributes cattr,
IElementAttributes attr)
Constructor for the Cache object |
Method Summary | |
---|---|
void |
addElementEvent(IElementEventHandler hand,
IElementEvent event)
Adds an ElementEvent to be handled to the queue. |
void |
dispose()
Flushes all cache items from memory to auxilliary caches and close the auxilliary caches. |
void |
dispose(boolean fromRemote)
Invoked only by CacheManager. |
ICacheElement |
get(java.io.Serializable key)
Gets an item from the cache. |
protected ICacheElement |
get(java.io.Serializable key,
boolean localOnly)
Look in memory, then disk, remote, or laterally for this item. |
ICompositeCacheAttributes |
getCacheAttributes()
Gets the ICompositeCacheAttributes attribute of the Cache object. |
java.lang.String |
getCacheName()
Gets the cacheName attribute of the Cache object. |
int |
getCacheType()
Gets the cacheType attribute of the Cache object. |
IElementAttributes |
getElementAttributes()
Gets the default element attribute of the Cache object This returna a copy. |
IElementAttributes |
getElementAttributes(java.io.Serializable key)
Gets the elementAttributes attribute of the Cache object. |
java.util.Set |
getGroupKeys(java.lang.String group)
Gets the set of keys of objects currently in the group. |
int |
getHitCountAux()
Number of times a requested item was found in and auxiliary cache. |
int |
getHitCountRam()
Number of times a requested item was found in the memory cache. |
MemoryCache |
getMemoryCache()
Access to the memory cache for instrumentation. |
int |
getMissCountExpired()
Number of times a requested element was found but was expired. |
int |
getMissCountNotFound()
Number of times a requested element was not found. |
int |
getRemoveCount()
|
int |
getSize()
Gets the size attribute of the Cache object. |
ICacheStats |
getStatistics()
This returns data gathered for this region and all the auxiliaries it currently uses. |
java.lang.String |
getStats()
Gets stats for debugging. |
int |
getStatus()
Gets the status attribute of the Cache object. |
int |
getUpdateCount()
|
ICacheElement |
localGet(java.io.Serializable key)
Do not try to go remote or laterally for this get. |
boolean |
localRemove(java.io.Serializable key)
Do not propogate removeall laterally or remotely. |
void |
localRemoveAll()
Will not pass the remove message remotely. |
void |
localUpdate(ICacheElement ce)
Standard update method. |
boolean |
remove(java.io.Serializable key)
Removes an item from the cache. |
protected boolean |
remove(java.io.Serializable key,
boolean localOnly)
fromRemote: If a remove call was made on a cache with both, then the remote should have been called. |
void |
removeAll()
Clears the region. |
protected void |
removeAll(boolean localOnly)
Removes all cached items. |
void |
save()
Calling save cause the entire contents of the memory cache to be flushed to all auxiliaries. |
void |
setAuxCaches(AuxiliaryCache[] auxCaches)
This sets the list of auxiliary caches for this region. |
void |
setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the ICompositeCacheAttributes attribute of the Cache object. |
void |
setElementAttributes(IElementAttributes attr)
Sets the default element attribute of the Cache object. |
void |
setRemoveCount(int removeCount)
|
void |
setUpdateCount(int updateCount)
|
void |
spoolToDisk(ICacheElement ce)
Writes the specified element to any disk auxilliaries. |
java.lang.String |
toString()
This returns the stats. |
void |
update(ICacheElement ce)
Standard update method. |
protected void |
update(ICacheElement cacheElement,
boolean localOnly)
Put an item into the cache. |
protected void |
updateAuxiliaries(ICacheElement cacheElement,
boolean localOnly)
This method is responsible for updating the auxiliaries if they are present. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static IElementEventQueue elementEventQ
Constructor Detail |
---|
public CompositeCache(java.lang.String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr)
cacheName
- The name of the regioncattr
- The cache attributeattr
- The default element attributesMethod Detail |
---|
public void setAuxCaches(AuxiliaryCache[] auxCaches)
auxCaches
- public void update(ICacheElement ce) throws java.io.IOException
update
in interface ICache
ce
-
java.io.IOException
public void localUpdate(ICacheElement ce) throws java.io.IOException
ce
-
java.io.IOException
protected void update(ICacheElement cacheElement, boolean localOnly) throws java.io.IOException
cacheElement
- the ICacheElementlocalOnly
- Whether the operation should be restricted to local auxiliaries.
java.io.IOException
protected void updateAuxiliaries(ICacheElement cacheElement, boolean localOnly) throws java.io.IOException
Before updating an auxiliary it checks to see if the element attributes permit the operation.
Disk auxiliaries are only updated if the disk cache is not merely used as a swap. If the disk cache is merely a swap, then items will only go to disk when they overflow from memory.
This is called by update( cacheElement, localOnly ) after it updates the memory cache.
This is protected to make it testable.
cacheElement
- localOnly
-
java.io.IOException
public void spoolToDisk(ICacheElement ce)
If JCS is not configured to use the disk as a swap, that is if the the CompositeCacheAttribute diskUsagePattern is not SWAP_ONLY, then the item will not be spooled.
ce
- The CacheElementpublic ICacheElement get(java.io.Serializable key)
get
in interface ICache
key
-
java.io.IOException
ICache.get(java.io.Serializable)
public ICacheElement localGet(java.io.Serializable key)
key
-
protected ICacheElement get(java.io.Serializable key, boolean localOnly)
Do not try to go remote or laterally for this get if it is localOnly. Otherwise try to go remote or lateral if such an auxiliary is configured for this region.
key
- localOnly
-
public java.util.Set getGroupKeys(java.lang.String group)
group
-
public boolean remove(java.io.Serializable key)
remove
in interface ICache
key
-
java.io.IOException
ICache.remove(java.io.Serializable)
public boolean localRemove(java.io.Serializable key)
key
-
protected boolean remove(java.io.Serializable key, boolean localOnly)
key
- localOnly
-
public void removeAll() throws java.io.IOException
removeAll
in interface ICache
java.io.IOException
ICache.removeAll()
public void localRemoveAll() throws java.io.IOException
java.io.IOException
protected void removeAll(boolean localOnly) throws java.io.IOException
localOnly
- must pass in false to get remote and lateral aux's updated. This prevents
looping.
java.io.IOException
public void dispose()
dispose
in interface ICache
public void dispose(boolean fromRemote)
fromRemote
- public void save()
public int getSize()
getSize
in interface ICache
public int getCacheType()
getCacheType
in interface ICacheType
public int getStatus()
getStatus
in interface ICache
public java.lang.String getStats()
getStats
in interface ICache
public ICacheStats getStatistics()
public java.lang.String getCacheName()
getCacheName
in interface ICache
public IElementAttributes getElementAttributes()
public void setElementAttributes(IElementAttributes attr)
attr
- public ICompositeCacheAttributes getCacheAttributes()
public void setCacheAttributes(ICompositeCacheAttributes cattr)
cattr
- The new ICompositeCacheAttributes valuepublic IElementAttributes getElementAttributes(java.io.Serializable key) throws CacheException, java.io.IOException
key
-
CacheException
java.io.IOException
public MemoryCache getMemoryCache()
public int getHitCountRam()
public int getHitCountAux()
public int getMissCountNotFound()
public int getMissCountExpired()
public void addElementEvent(IElementEventHandler hand, IElementEvent event) throws java.io.IOException
hand
- The IElementEventHandlerevent
- The IElementEventHandler IElementEvent event
java.io.IOException
- Description of the Exceptionpublic void setUpdateCount(int updateCount)
updateCount
- The updateCount to set.public int getUpdateCount()
public void setRemoveCount(int removeCount)
removeCount
- The removeCount to set.public int getRemoveCount()
public java.lang.String toString()
(non-Javadoc)
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |