org.apache.jcs.access.behavior
Interface ICacheAccess<K extends Serializable,V extends Serializable>

All Known Implementing Classes:
CacheAccess, GroupCacheAccess, JCS, PartitionedCacheAccess

public interface ICacheAccess<K extends Serializable,V extends Serializable>

ICacheAccess defines the behavior for client access.


Method Summary
 int freeMemoryElements(int numberToFree)
          This instructs the memory cache to remove the numberToFree according to its eviction policy.
 V get(K name)
          Basic get method.
 ICompositeCacheAttributes getCacheAttributes()
          Gets the ICompositeCacheAttributes of the cache region
 ICacheElement<K,V> getCacheElement(K name)
          This method returns the ICacheElement wrapper which provides access to element info and other attributes.
 Map<K,ICacheElement<K,V>> getCacheElements(Set<K> names)
          Get multiple elements from the cache based on a set of cache keys.
 IElementAttributes getElementAttributes()
          GetElementAttributes will return an attribute object describing the current attributes associated with the object name.
 IElementAttributes getElementAttributes(K name)
          Gets the elementAttributes attribute of the ICacheAccess object
 Map<K,V> getMatching(String pattern)
          Retrieve matching objects from the cache region this instance provides access to.
 Map<K,ICacheElement<K,V>> getMatchingCacheElements(String pattern)
          Get multiple elements from the cache based on a set of cache keys.
 void put(K name, V obj)
          Puts and/or overrides an element with the name in that region.
 void put(K name, V obj, IElementAttributes attr)
          Description of the Method
 void putSafe(K name, V obj)
          Puts in cache if an item does not exist with the name in that region.
 void remove()
          Old remove all method.
 void remove(K name)
          Remove an object for this key if one exists, else do nothing.
 void resetElementAttributes(IElementAttributes attributes)
          ResetAttributes allows for some of the attributes of a region to be reset in particular expiration time attributes, time to live, default time to live and idle time, and event handlers.
 void resetElementAttributes(K name, IElementAttributes attributes)
          Reset the attributes on the object matching this key name.
 void setCacheAttributes(ICompositeCacheAttributes cattr)
          Sets the ICompositeCacheAttributes of the cache region
 

Method Detail

get

V get(K name)
Basic get method.

Parameters:
name -
Returns:
Object or null if not found.

getMatching

Map<K,V> getMatching(String pattern)
Retrieve matching objects from the cache region this instance provides access to.

Parameters:
pattern - - a key pattern for the objects stored
Returns:
A map of key to values. These are stripped from the wrapper.

putSafe

void putSafe(K name,
             V obj)
             throws CacheException
Puts in cache if an item does not exist with the name in that region.

Parameters:
name -
obj -
Throws:
CacheException

put

void put(K name,
         V obj)
         throws CacheException
Puts and/or overrides an element with the name in that region.

Parameters:
name -
obj -
Throws:
CacheException

put

void put(K name,
         V obj,
         IElementAttributes attr)
         throws CacheException
Description of the Method

Parameters:
name -
obj -
attr -
Throws:
CacheException

getCacheElement

ICacheElement<K,V> getCacheElement(K name)
This method returns the ICacheElement wrapper which provides access to element info and other attributes.

This returns a reference to the wrapper. Any modifications will be reflected in the cache. No defensive copy is made.

This method is most useful if you want to determine things such as the how long the element has been in the cache.

The last access time in the ElementAttributes should be current.

Parameters:
name - Key the object is stored as
Returns:
The ICacheElement if the object is found or null

getCacheElements

Map<K,ICacheElement<K,V>> getCacheElements(Set<K> names)
Get multiple elements from the cache based on a set of cache keys.

This method returns the ICacheElement wrapper which provides access to element info and other attributes.

This returns a reference to the wrapper. Any modifications will be reflected in the cache. No defensive copy is made.

This method is most useful if you want to determine things such as the how long the element has been in the cache.

The last access time in the ElementAttributes should be current.

Parameters:
names - set of Object cache keys
Returns:
a map of Object key to ICacheElement element, or empty map if none of the keys are present

getMatchingCacheElements

Map<K,ICacheElement<K,V>> getMatchingCacheElements(String pattern)
Get multiple elements from the cache based on a set of cache keys.

This method returns the ICacheElement wrapper which provides access to element info and other attributes.

This returns a reference to the wrapper. Any modifications will be reflected in the cache. No defensive copy is made.

This method is most useful if you want to determine things such as the how long the element has been in the cache.

The last access time in the ElementAttributes should be current.

Parameters:
pattern - key search pattern
Returns:
a map of Object key to ICacheElement element, or empty map if no keys match the pattern

remove

void remove()
            throws CacheException
Old remove all method.

Throws:
CacheException

remove

void remove(K name)
            throws CacheException
Remove an object for this key if one exists, else do nothing.

Parameters:
name -
Throws:
CacheException

resetElementAttributes

void resetElementAttributes(IElementAttributes attributes)
                            throws CacheException
ResetAttributes allows for some of the attributes of a region to be reset in particular expiration time attributes, time to live, default time to live and idle time, and event handlers. The cacheloader object and attributes set as flags can't be reset with resetAttributes, the object must be destroyed and redefined to cache those parameters. Changing default settings on groups and regions will not affect existing objects. Only object loaded after the reset will use the new defaults. If no name argument is provided, the reset is applied to the region.

Parameters:
attributes -
Throws:
CacheException

resetElementAttributes

void resetElementAttributes(K name,
                            IElementAttributes attributes)
                            throws CacheException
Reset the attributes on the object matching this key name.

Parameters:
name -
attributes -
Throws:
CacheException

getElementAttributes

IElementAttributes getElementAttributes()
                                        throws CacheException
GetElementAttributes will return an attribute object describing the current attributes associated with the object name. If no name parameter is available, the attributes for the region will be returned. The name object must override the Object.equals and Object.hashCode methods.

Returns:
The elementAttributes value
Throws:
CacheException

getElementAttributes

IElementAttributes getElementAttributes(K name)
                                        throws CacheException
Gets the elementAttributes attribute of the ICacheAccess object

Parameters:
name -
Returns:
The elementAttributes value
Throws:
CacheException

getCacheAttributes

ICompositeCacheAttributes getCacheAttributes()
Gets the ICompositeCacheAttributes of the cache region

Returns:
ICompositeCacheAttributes

setCacheAttributes

void setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the ICompositeCacheAttributes of the cache region

Parameters:
cattr - The new ICompositeCacheAttribute value

freeMemoryElements

int freeMemoryElements(int numberToFree)
                       throws CacheException
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:
CacheException


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