org.apache.jcs.engine.behavior
Interface ICache

All Superinterfaces:
ICacheType, java.io.Serializable
All Known Subinterfaces:
AuxiliaryCache, IRemoteCacheClient
All Known Implementing Classes:
AbstractAuxiliaryCache, AbstractAuxiliaryCacheEventLogging, AbstractDiskCache, AbstractRemoteAuxiliaryCache, AbstractRemoteCacheNoWaitFacade, BlockDiskCache, CompositeCache, IndexedDiskCache, JDBCDiskCache, LateralCache, LateralCacheNoWait, LateralCacheNoWaitFacade, MySQLDiskCache, RemoteCache, RemoteCacheNoWait, RemoteCacheNoWaitFacade, RemoteHttpCache

public interface ICache
extends ICacheType

This is the top level interface for all cache like structures. It defines the methods used internally by JCS to access, modify, and instrument such structures.

This allows for a suite of reusable components for accessing such structures, for example asynchronous access via an event queue.


Field Summary
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE
 
Method Summary
 void dispose()
          Prepares for shutdown.
 ICacheElement get(java.io.Serializable key)
          Gets an item from the cache.
 java.lang.String getCacheName()
          Returns the cache name.
 java.util.Map getMatching(java.lang.String pattern)
          Gets items from the cache matching the given pattern.
 java.util.Map getMultiple(java.util.Set keys)
          Gets multiple items from the cache based on the given set of keys.
 int getSize()
          Returns the current cache size in number of elements.
 java.lang.String getStats()
          Returns the cache stats.
 int getStatus()
          Returns the cache status.
 boolean remove(java.io.Serializable key)
          Removes an item from the cache.
 void removeAll()
          Removes all cached items from the cache.
 void setKeyMatcher(IKeyMatcher keyMatcher)
          Sets the key matcher used by get matching.
 void update(ICacheElement element)
          Puts an item to the cache.
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICacheType
getCacheType
 

Method Detail

update

void update(ICacheElement element)
            throws java.io.IOException
Puts an item to the cache.

Parameters:
element -
Throws:
java.io.IOException

get

ICacheElement get(java.io.Serializable key)
                  throws java.io.IOException
Gets an item from the cache.

Parameters:
key -
Returns:
a cache element, or null if there is no data in cache for this key
Throws:
java.io.IOException

getMultiple

java.util.Map getMultiple(java.util.Set keys)
                          throws java.io.IOException
Gets multiple items from the cache based on the given set of keys.

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

getMatching

java.util.Map getMatching(java.lang.String pattern)
                          throws java.io.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 Serializable key to ICacheElement element, or an empty map if there is no data matching the pattern.
Throws:
java.io.IOException

remove

boolean remove(java.io.Serializable key)
               throws java.io.IOException
Removes an item from the cache.

Parameters:
key -
Returns:
false if there was an error in removal
Throws:
java.io.IOException

removeAll

void removeAll()
               throws java.io.IOException
Removes all cached items from the cache.

Throws:
java.io.IOException

dispose

void dispose()
             throws java.io.IOException
Prepares for shutdown.

Throws:
java.io.IOException

getSize

int getSize()
Returns the current cache size in number of elements.

Returns:
number of elements

getStatus

int getStatus()
Returns the cache status.

Returns:
Alive or Error

getStats

java.lang.String getStats()
Returns the cache stats.

Returns:
String of important historical information.

getCacheName

java.lang.String getCacheName()
Returns the cache name.

Returns:
usually the region name.

setKeyMatcher

void setKeyMatcher(IKeyMatcher keyMatcher)
Sets the key matcher used by get matching.

Parameters:
keyMatcher -


Copyright © 2002-2011 Apache Software Foundation. All Rights Reserved.