org.apache.jcs.auxiliary
Class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>

java.lang.Object
  extended by org.apache.jcs.auxiliary.AbstractAuxiliaryCache<K,V>
      extended by org.apache.jcs.auxiliary.AbstractAuxiliaryCacheEventLogging<K,V>
All Implemented Interfaces:
AuxiliaryCache<K,V>, ICache<K,V>, ICacheType
Direct Known Subclasses:
AbstractDiskCache, AbstractRemoteAuxiliaryCache, LateralCache

public abstract class AbstractAuxiliaryCacheEventLogging<K extends Serializable,V extends Serializable>
extends AbstractAuxiliaryCache<K,V>

All ICacheEvents are defined as final. Children must implement process events. These are wrapped in event log parent calls.

You can override the public method, but if you don't, the default will call getWithTiming.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.jcs.engine.behavior.ICacheType
ICacheType.CacheType
 
Field Summary
 
Fields inherited from class org.apache.jcs.auxiliary.AbstractAuxiliaryCache
cacheEventLogger, elementSerializer, keyMatcher
 
Constructor Summary
AbstractAuxiliaryCacheEventLogging()
           
 
Method Summary
 void dispose()
          Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.
protected  void disposeWithEventLogging()
          Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.
 ICacheElement<K,V> get(K key)
          Gets the item from the cache.
 Map<K,ICacheElement<K,V>> getMatching(String pattern)
          Gets items from the cache matching the given pattern.
protected  Map<K,ICacheElement<K,V>> getMatchingWithEventLogging(String pattern)
          Gets mmatching items from the cache based on the given pattern.
 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>> getMultipleWithEventLogging(Set<K> keys)
          Gets multiple items from the cache based on the given set of keys.
protected  ICacheElement<K,V> getWithEventLogging(K key)
          Gets the item from the cache.
protected abstract  void processDispose()
          Specific implementation of dispose.
protected abstract  ICacheElement<K,V> processGet(K key)
          Implementation of get.
protected abstract  Map<K,ICacheElement<K,V>> processGetMatching(String pattern)
          Implementation of getMatching.
protected abstract  Map<K,ICacheElement<K,V>> processGetMultiple(Set<K> keys)
          Implementation of getMultiple.
protected abstract  boolean processRemove(K key)
          Specific implementation of remove.
protected abstract  void processRemoveAll()
          Specific implementation of removeAll.
protected abstract  void processUpdate(ICacheElement<K,V> cacheElement)
          Implementation of put.
 boolean remove(K key)
          Removes the item from the cache.
 void removeAll()
          Removes all from the region.
protected  void removeAllWithEventLogging()
          Removes all from the region.
protected  boolean removeWithEventLogging(K key)
          Removes the item from the cache.
 void update(ICacheElement<K,V> cacheElement)
          Puts an item into the cache.
protected  void updateWithEventLogging(ICacheElement<K,V> cacheElement)
          Puts an item into the cache.
 
Methods inherited from class org.apache.jcs.auxiliary.AbstractAuxiliaryCache
createICacheEvent, createICacheEvent, getCacheEventLogger, getElementSerializer, getEventLoggingExtraInfo, getKeyMatcher, logApplicationEvent, logError, logICacheEvent, setCacheEventLogger, setElementSerializer, setKeyMatcher
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jcs.auxiliary.AuxiliaryCache
getAuxiliaryCacheAttributes, getGroupKeys, getGroupNames, getStatistics
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICache
getCacheName, getSize, getStats, getStatus
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICacheType
getCacheType
 

Constructor Detail

AbstractAuxiliaryCacheEventLogging

public AbstractAuxiliaryCacheEventLogging()
Method Detail

update

public void update(ICacheElement<K,V> cacheElement)
            throws IOException
Puts an item into the cache.

Parameters:
cacheElement -
Throws:
IOException

updateWithEventLogging

protected final void updateWithEventLogging(ICacheElement<K,V> cacheElement)
                                     throws IOException
Puts an item into the cache. Wrapped in logging.

Parameters:
cacheElement -
Throws:
IOException

processUpdate

protected abstract void processUpdate(ICacheElement<K,V> cacheElement)
                               throws IOException
Implementation of put.

Parameters:
cacheElement -
Throws:
IOException

get

public ICacheElement<K,V> get(K key)
                                                                 throws IOException
Gets the item from the cache.

Parameters:
key -
Returns:
ICacheElement, a wrapper around the key, value, and attributes
Throws:
IOException

getWithEventLogging

protected final ICacheElement<K,V> getWithEventLogging(K key)
                                                                                          throws IOException
Gets the item from the cache. Wrapped in logging.

Parameters:
key -
Returns:
ICacheElement, a wrapper around the key, value, and attributes
Throws:
IOException

processGet

protected abstract ICacheElement<K,V> processGet(K key)
                                                                                    throws IOException
Implementation of get.

Parameters:
key -
Returns:
ICacheElement, a wrapper around the key, value, and attributes
Throws:
IOException

getMultiple

public Map<K,ICacheElement<K,V>> getMultiple(Set<K> keys)
                                                                                                     throws IOException
Gets multiple items from the cache based on the given set of keys.

Parameters:
keys -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
Throws:
IOException

getMultipleWithEventLogging

protected final Map<K,ICacheElement<K,V>> getMultipleWithEventLogging(Set<K> keys)
                                                                                                                              throws IOException
Gets multiple items from the cache based on the given set of keys.

Parameters:
keys -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
Throws:
IOException

processGetMultiple

protected abstract Map<K,ICacheElement<K,V>> processGetMultiple(Set<K> keys)
                                                                                                                        throws IOException
Implementation of getMultiple.

Parameters:
keys -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
Throws:
IOException

getMatching

public Map<K,ICacheElement<K,V>> getMatching(String pattern)
                                                                                                     throws IOException
Gets items from the cache matching the given pattern. Items from memory will replace those from remote sources.

This only works with string keys. It's too expensive to do a toString on every key.

Auxiliaries will do their best to handle simple expressions. For instance, the JDBC disk cache will convert * to % and . to _

Parameters:
pattern -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data matching the pattern.
Throws:
IOException

getMatchingWithEventLogging

protected final Map<K,ICacheElement<K,V>> getMatchingWithEventLogging(String pattern)
                                                                                                                              throws IOException
Gets mmatching items from the cache based on the given pattern.

Parameters:
pattern -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data matching the pattern.
Throws:
IOException

processGetMatching

protected abstract Map<K,ICacheElement<K,V>> processGetMatching(String pattern)
                                                                                                                        throws IOException
Implementation of getMatching.

Parameters:
pattern -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data matching the pattern.
Throws:
IOException

remove

public boolean remove(K key)
               throws IOException
Removes the item from the cache. Wraps the remove in event logs.

Parameters:
key -
Returns:
boolean, whether or not the item was removed
Throws:
IOException

removeWithEventLogging

protected final boolean removeWithEventLogging(K key)
                                        throws IOException
Removes the item from the cache. Wraps the remove in event logs.

Parameters:
key -
Returns:
boolean, whether or not the item was removed
Throws:
IOException

processRemove

protected abstract boolean processRemove(K key)
                                  throws IOException
Specific implementation of remove.

Parameters:
key -
Returns:
boolean, whether or not the item was removed
Throws:
IOException

removeAll

public void removeAll()
               throws IOException
Removes all from the region. Wraps the removeAll in event logs.

Throws:
IOException

removeAllWithEventLogging

protected final void removeAllWithEventLogging()
                                        throws IOException
Removes all from the region. Wraps the removeAll in event logs.

Throws:
IOException

processRemoveAll

protected abstract void processRemoveAll()
                                  throws IOException
Specific implementation of removeAll.

Throws:
IOException

dispose

public void dispose()
             throws IOException
Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.

Throws:
IOException

disposeWithEventLogging

protected final void disposeWithEventLogging()
                                      throws IOException
Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie. Wraps the removeAll in event logs.

Throws:
IOException

processDispose

protected abstract void processDispose()
                                throws IOException
Specific implementation of dispose.

Throws:
IOException


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.