org.apache.jcs.engine.memory.behavior
Interface IMemoryCache

All Known Subinterfaces:
MemoryCache
All Known Implementing Classes:
AbstractDoulbeLinkedListMemoryCache, AbstractMemoryCache, FIFOMemoryCache, LRUMemoryCache, MRUMemoryCache

public interface IMemoryCache

For the framework. Insures methods a MemoryCache needs to access.


Method Summary
 void dispose()
          Destroy the memory cache
 int freeElements(int numberToFree)
          This instructs the memory cache to remove the numberToFree according to its eviction policy.
 ICacheElement get(java.io.Serializable key)
          Get an item from the cache
 ICompositeCacheAttributes getCacheAttributes()
          Returns the CacheAttributes for the region.
 CompositeCache getCompositeCache()
          Gets the cache hub / region that uses the MemoryCache.
 java.util.Set getGroupKeys(java.lang.String group)
          Gets the set of keys of objects currently in the group.
 java.util.Iterator getIterator()
          Get an iterator for all elements in the memory cache.
 java.lang.Object[] getKeyArray()
          Get an Array of the keys for all elements in the memory cache.
 java.util.Map getMultiple(java.util.Set keys)
          Gets multiple items from the cache based on the given set of keys.
 ICacheElement getQuiet(java.io.Serializable key)
          Get an item from the cache without effecting its order or last access time
 int getSize()
          Get the number of elements contained in the memory store
 IStats getStatistics()
          Returns the historical and statistical data for a region's memory cache.
 void initialize(CompositeCache cache)
          Initialize the memory cache
 boolean remove(java.io.Serializable key)
          Removes an item from the cache
 void removeAll()
          Removes all cached items from the cache.
 void setCacheAttributes(ICompositeCacheAttributes cattr)
          Sets the CacheAttributes of the region.
 void update(ICacheElement ce)
          Puts an item to the cache.
 void waterfal(ICacheElement ce)
          Spools the item contained in the provided element to disk
 

Method Detail

initialize

void initialize(CompositeCache cache)
Initialize the memory cache

Parameters:
cache - The cache (region) this memory store is attached to.

dispose

void dispose()
             throws java.io.IOException
Destroy the memory cache

Throws:
java.io.IOException

getSize

int getSize()
Get the number of elements contained in the memory store

Returns:
Element count

getStatistics

IStats getStatistics()
Returns the historical and statistical data for a region's memory cache.

Returns:
Statistics and Infor for the Memory Cache.

getIterator

java.util.Iterator getIterator()
Get an iterator for all elements in the memory cache. This should be removed since it is fairly dangerous. Other classes should not be able to directly access items in the memory cache.

Returns:
An iterator

getKeyArray

java.lang.Object[] getKeyArray()
Get an Array of the keys for all elements in the memory cache.

Returns:
Object[]

remove

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

Parameters:
key - Identifies item to be removed
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

removeAll

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

Throws:
java.io.IOException - Description of the Exception

freeElements

int freeElements(int numberToFree)
                 throws java.io.IOException
This instructs the memory cache to remove the numberToFree according to its eviction policy. For example, the LRUMemoryCache will remove the numberToFree least recently used items. These will be spooled to disk if a disk auxiliary is available.

Parameters:
numberToFree -
Returns:
the number that were removed. if you ask to free 5, but there are only 3, you will get 3.
Throws:
java.io.IOException

get

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

Parameters:
key - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception

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

getQuiet

ICacheElement getQuiet(java.io.Serializable key)
                       throws java.io.IOException
Get an item from the cache without effecting its order or last access time

Parameters:
key - Description of the Parameter
Returns:
The quiet value
Throws:
java.io.IOException - Description of the Exception

waterfal

void waterfal(ICacheElement ce)
              throws java.io.IOException
Spools the item contained in the provided element to disk

Parameters:
ce - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

update

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

Parameters:
ce - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

getCacheAttributes

ICompositeCacheAttributes getCacheAttributes()
Returns the CacheAttributes for the region.

Returns:
The cacheAttributes value

setCacheAttributes

void setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the CacheAttributes of the region.

Parameters:
cattr - The new cacheAttributes value

getCompositeCache

CompositeCache getCompositeCache()
Gets the cache hub / region that uses the MemoryCache.

Returns:
The cache value

getGroupKeys

java.util.Set getGroupKeys(java.lang.String group)
Gets the set of keys of objects currently in the group.

Parameters:
group -
Returns:
a Set of group keys.


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