Class CacheAccess<K,V> 
- All Implemented Interfaces:
- ICacheAccess<K,,- V> - ICacheAccessManagement
An instance of this class is tied to a specific cache region. Static methods are provided to get such instances.
Using this class you can retrieve an item, the item's wrapper, and the element's configuration. You can also put an item in the cache, remove an item, and clear a region.
The JCS class is the preferred way to access these methods.
- 
Constructor SummaryConstructorsConstructorDescriptionCacheAccess(CompositeCache<K, V> cacheControl) Constructor for the CacheAccess object.
- 
Method SummaryModifier and TypeMethodDescriptionRetrieve an object from the cache region this instance provides access to.Retrieve an object from the cache region this instance provides access to.getCacheElement(K name) This method returns the ICacheElement<K, V> 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.getElementAttributes(K name) GetElementAttributes will return an attribute object describing the current attributes associated with the object name.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.voidPlace a new object in the cache, associated with key name.voidput(K key, V val, IElementAttributes attr) Constructs a cache element with these attributes, and puts it into the cache.voidPlace a new object in the cache, associated with key name.voidRemoves a single item by name.voidresetElementAttributes(K name, IElementAttributes attr) Reset attributes for a particular element in the cache.Methods inherited from class org.apache.commons.jcs3.access.AbstractCacheAccessclear, dispose, freeMemoryElements, getCacheAttributes, getCacheControl, getDefaultElementAttributes, getStatistics, getStats, setCacheAttributes, setDefaultElementAttributesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.jcs3.access.behavior.ICacheAccessManagementclear, dispose, freeMemoryElements, getCacheAttributes, getDefaultElementAttributes, getStatistics, getStats, setCacheAttributes, setDefaultElementAttributes
- 
Constructor Details- 
CacheAccessConstructor for the CacheAccess object.- Parameters:
- cacheControl- The cache which the created instance accesses
 
 
- 
- 
Method Details- 
getRetrieve an object from the cache region this instance provides access to.- Specified by:
- getin interface- ICacheAccess<K,- V> 
- Parameters:
- name- Key the object is stored as
- Returns:
- The object if found or null
 
- 
getRetrieve an object from the cache region this instance provides access to. If the object cannot be found in the cache, it will be retrieved by calling the supplier and subsequently storing it in the cache.- Specified by:
- getin interface- ICacheAccess<K,- V> 
- Parameters:
- name-
- supplier- supplier to be called if the value is not found
- Returns:
- Object.
 
- 
getMatchingRetrieve matching objects from the cache region this instance provides access to.- Specified by:
- getMatchingin interface- ICacheAccess<K,- V> 
- Parameters:
- pattern- - a key pattern for the objects stored
- Returns:
- A map of key to values. These are stripped from the wrapper.
 
- 
getCacheElementThis method returns the ICacheElement<K, V> 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. - Specified by:
- getCacheElementin interface- ICacheAccess<K,- V> 
- Parameters:
- name- Key the Serializable is stored as
- Returns:
- The ICacheElement<K, V> if the object is found or null
 
- 
getCacheElementsGet multiple elements from the cache based on a set of cache keys.This method returns the ICacheElement<K, V> 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. - Specified by:
- getCacheElementsin interface- ICacheAccess<K,- V> 
- Parameters:
- names- set of Serializable cache keys
- Returns:
- a map of K key to ICacheElement<K, V> element, or empty map if none of the keys are present
 
- 
getMatchingCacheElementsGet multiple elements from the cache based on a set of cache keys.This method returns the ICacheElement<K, V> 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. - Specified by:
- getMatchingCacheElementsin interface- ICacheAccess<K,- V> 
- Parameters:
- pattern- key search pattern
- Returns:
- a map of K key to ICacheElement<K, V> element, or empty map if no keys match the pattern
 
- 
putSafePlace a new object in the cache, associated with key name. If there is currently an object associated with name in the region an ObjectExistsException is thrown. Names are scoped to a region so they must be unique within the region they are placed.- Specified by:
- putSafein interface- ICacheAccess<K,- V> 
- Parameters:
- key- Key object will be stored with
- value- Object to store
- Throws:
- CacheException- and ObjectExistsException is thrown if the item is already in the cache.
 
- 
putPlace a new object in the cache, associated with key name. If there is currently an object associated with name in the region it is replaced. Names are scoped to a region so they must be unique within the region they are placed.- Specified by:
- putin interface- ICacheAccess<K,- V> 
- Parameters:
- name- Key object will be stored with
- obj- Object to store
 
- 
putConstructs a cache element with these attributes, and puts it into the cache.If the key or the value is null, and InvalidArgumentException is thrown. - Specified by:
- putin interface- ICacheAccess<K,- V> 
- See Also:
 
- 
removeRemoves a single item by name.- Specified by:
- removein interface- ICacheAccess<K,- V> 
- Parameters:
- name- the name of the item to remove.
 
- 
resetElementAttributesReset attributes for a particular element in the cache. NOTE: this method is currently not implemented.- Specified by:
- resetElementAttributesin interface- ICacheAccess<K,- V> 
- Parameters:
- name- Key of object to reset attributes for
- attr- New attributes for the object
- Throws:
- InvalidHandleException- if the item does not exist.
 
- 
getElementAttributesGetElementAttributes will return an attribute object describing the current attributes associated with the object name. The name object must override the Object.equals and Object.hashCode methods.- Specified by:
- getElementAttributesin interface- ICacheAccess<K,- V> 
- Parameters:
- name- Key of object to get attributes for
- Returns:
- Attributes for the object, null if object not in cache
- Throws:
- CacheException
 
 
-