|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jcs.engine.control.CompositeCache<K,V>
public class CompositeCache<K extends Serializable,V extends Serializable>
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.apache.jcs.engine.behavior.ICacheType |
|---|
ICacheType.CacheType |
| Field Summary | |
|---|---|
IElementEventQueue |
elementEventQ
EventQueue for handling element events. |
protected IKeyMatcher<K> |
keyMatcher
Key matcher used by the getMatching API |
| Constructor Summary | |
|---|---|
CompositeCache(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 auxiliary caches and close the auxiliary caches. |
void |
dispose(boolean fromRemote)
Invoked only by CacheManager. |
ICacheElement<K,V> |
get(K key)
Gets an item from the cache. |
protected ICacheElement<K,V> |
get(K key,
boolean localOnly)
Look in memory, then disk, remote, or laterally for this item. |
AuxiliaryCache<K,V>[] |
getAuxCaches()
Get the list of auxiliary caches for this region. |
ICompositeCacheAttributes |
getCacheAttributes()
Gets the ICompositeCacheAttributes attribute of the Cache object. |
String |
getCacheName()
Gets the cacheName attribute of the Cache object. |
ICacheType.CacheType |
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(K key)
Gets the elementAttributes attribute of the Cache object. |
Set<K> |
getGroupKeys(String group)
Gets the set of keys of objects currently in the group. |
Set<K> |
getGroupKeys(String group,
boolean localOnly)
Gets the set of keys of objects currently in the group. |
Set<String> |
getGroupNames()
Gets the set of group names in the cache |
Set<String> |
getGroupNames(boolean localOnly)
Gets the set of group names in the cache |
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. |
IKeyMatcher<K> |
getKeyMatcher()
Returns the key matcher used by get matching. |
Map<K,ICacheElement<K,V>> |
getMatching(String pattern)
Build a map of all the matching elements in all of the auxiliaries and memory. |
protected Map<K,ICacheElement<K,V>> |
getMatching(String pattern,
boolean localOnly)
Build a map of all the matching elements in all of the auxiliaries and memory. |
protected Map<K,ICacheElement<K,V>> |
getMatchingFromMemory(String pattern)
Gets the key array from the memcache. |
IMemoryCache<K,V> |
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. |
Map<K,ICacheElement<K,V>> |
getMultiple(Set<K> keys)
Gets multiple items from the cache based on the given set of keys. |
protected Map<K,ICacheElement<K,V>> |
getMultiple(Set<K> keys,
boolean localOnly)
Look in memory, then disk, remote, or laterally for these items. |
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. |
String |
getStats()
Gets stats for debugging. |
CacheStatus |
getStatus()
Gets the status attribute of the Cache object. |
int |
getUpdateCount()
|
protected boolean |
isExpired(ICacheElement<K,V> element)
Determine if the element has exceeded its max life. |
ICacheElement<K,V> |
localGet(K key)
Do not try to go remote or laterally for this get. |
Map<K,ICacheElement<K,V>> |
localGetMatching(String pattern)
Build a map of all the matching elements in all of the auxiliaries and memory. |
Map<K,ICacheElement<K,V>> |
localGetMultiple(Set<K> keys)
Gets multiple items from the cache based on the given set of keys. |
boolean |
localRemove(K key)
Do not propagate removeall laterally or remotely. |
void |
localRemoveAll()
Will not pass the remove message remotely. |
void |
localUpdate(ICacheElement<K,V> ce)
Standard update method. |
boolean |
remove(K key)
Removes an item from the cache. |
protected boolean |
remove(K 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<K,V>[] 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 |
setKeyMatcher(IKeyMatcher<K> keyMatcher)
Sets the key matcher used by get matching. |
void |
setRemoveCount(int removeCount)
|
void |
setUpdateCount(int updateCount)
|
void |
spoolToDisk(ICacheElement<K,V> ce)
Writes the specified element to any disk auxiliaries. |
String |
toString()
This returns the stats. |
void |
update(ICacheElement<K,V> ce)
Standard update method. |
protected void |
update(ICacheElement<K,V> cacheElement,
boolean localOnly)
Put an item into the cache. |
protected void |
updateAuxiliaries(ICacheElement<K,V> 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 IElementEventQueue elementEventQ
protected IKeyMatcher<K extends Serializable> keyMatcher
| Constructor Detail |
|---|
public CompositeCache(String cacheName,
ICompositeCacheAttributes cattr,
IElementAttributes attr)
cacheName - The name of the regioncattr - The cache attributeattr - The default element attributes| Method Detail |
|---|
public void setAuxCaches(AuxiliaryCache<K,V>[] auxCaches)
auxCaches - public AuxiliaryCache<K,V>[] getAuxCaches()
public void update(ICacheElement<K,V> ce)
throws IOException
update in interface ICache<K extends Serializable,V extends Serializable>ce -
IOException
public void localUpdate(ICacheElement<K,V> ce)
throws IOException
ce -
IOException
protected void update(ICacheElement<K,V> cacheElement,
boolean localOnly)
throws IOException
cacheElement - the ICacheElementlocalOnly - Whether the operation should be restricted to local auxiliaries.
IOException
protected void updateAuxiliaries(ICacheElement<K,V> cacheElement,
boolean localOnly)
throws 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 -
IOExceptionpublic void spoolToDisk(ICacheElement<K,V> 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<K,V> get(K key)
get in interface ICache<K extends Serializable,V extends Serializable>key -
ICache.get(java.io.Serializable)public ICacheElement<K,V> localGet(K key)
key -
protected ICacheElement<K,V> get(K 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 Map<K,ICacheElement<K,V>> getMultiple(Set<K> keys)
getMultiple in interface ICache<K extends Serializable,V extends Serializable>keys -
public Map<K,ICacheElement<K,V>> localGetMultiple(Set<K> keys)
keys -
protected Map<K,ICacheElement<K,V>> getMultiple(Set<K> keys,
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.
keys - localOnly -
public Map<K,ICacheElement<K,V>> getMatching(String pattern)
getMatching in interface ICache<K extends Serializable,V extends Serializable>pattern -
public Map<K,ICacheElement<K,V>> localGetMatching(String pattern)
pattern -
protected Map<K,ICacheElement<K,V>> getMatching(String pattern,
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.
pattern - localOnly -
protected Map<K,ICacheElement<K,V>> getMatchingFromMemory(String pattern)
throws IOException
pattern -
IOExceptionprotected boolean isExpired(ICacheElement<K,V> element)
element -
public Set<K> getGroupKeys(String group)
group - the name of the group
public Set<K> getGroupKeys(String group,
boolean localOnly)
group - the name of the group
public Set<String> getGroupNames()
public Set<String> getGroupNames(boolean localOnly)
localOnly - whether to get the group names only from local caches or not
public boolean remove(K key)
remove in interface ICache<K extends Serializable,V extends Serializable>key -
ICache.remove(java.io.Serializable)public boolean localRemove(K key)
key -
protected boolean remove(K key,
boolean localOnly)
key - localOnly -
public void removeAll()
throws IOException
removeAll in interface ICache<K extends Serializable,V extends Serializable>IOExceptionICache.removeAll()
public void localRemoveAll()
throws IOException
IOException
protected void removeAll(boolean localOnly)
throws IOException
localOnly - must pass in false to get remote and lateral aux's updated. This prevents
looping.
IOExceptionpublic void dispose()
dispose in interface ICache<K extends Serializable,V extends Serializable>public void dispose(boolean fromRemote)
fromRemote - public void save()
public int getSize()
getSize in interface ICache<K extends Serializable,V extends Serializable>public ICacheType.CacheType getCacheType()
getCacheType in interface ICacheTypepublic CacheStatus getStatus()
getStatus in interface ICache<K extends Serializable,V extends Serializable>public String getStats()
getStats in interface ICache<K extends Serializable,V extends Serializable>public ICacheStats getStatistics()
public String getCacheName()
getCacheName in interface ICache<K extends Serializable,V extends Serializable>public IElementAttributes getElementAttributes()
public void setElementAttributes(IElementAttributes attr)
attr - public ICompositeCacheAttributes getCacheAttributes()
public void setCacheAttributes(ICompositeCacheAttributes cattr)
cattr - The new ICompositeCacheAttributes value
public IElementAttributes getElementAttributes(K key)
throws CacheException,
IOException
key -
CacheException
IOExceptionpublic IMemoryCache<K,V> getMemoryCache()
public int getHitCountRam()
public int getHitCountAux()
public int getMissCountNotFound()
public int getMissCountExpired()
public void addElementEvent(IElementEventHandler hand,
IElementEvent event)
throws IOException
hand - The IElementEventHandlerevent - The IElementEventHandler IElementEvent event
IOException - Description of the Exceptionpublic void setKeyMatcher(IKeyMatcher<K> keyMatcher)
setKeyMatcher in interface ICache<K extends Serializable,V extends Serializable>keyMatcher - public IKeyMatcher<K> getKeyMatcher()
public 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 String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||