public class CacheAccess<K,V> extends AbstractCacheAccess<K,V> implements ICacheAccess<K,V>
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 and Description |
---|
CacheAccess(CompositeCache<K,V> cacheControl)
Constructor for the CacheAccess object.
|
Modifier and Type | Method and Description |
---|---|
V |
get(K name)
Retrieve an object from the cache region this instance provides access to.
|
ICacheElement<K,V> |
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.
|
IElementAttributes |
getElementAttributes(K name)
GetElementAttributes will return an attribute object describing the current attributes
associated with the object name.
|
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)
Place a new object in the cache, associated with key name.
|
void |
put(K key,
V val,
IElementAttributes attr)
Constructs a cache element with these attributes, and puts it into the cache.
|
void |
putSafe(K key,
V value)
Place a new object in the cache, associated with key name.
|
void |
remove(K name)
Removes a single item by name.
|
void |
resetElementAttributes(K name,
IElementAttributes attr)
Reset attributes for a particular element in the cache.
|
clear, dispose, freeMemoryElements, getCacheAttributes, getCacheControl, getDefaultElementAttributes, getStatistics, getStats, setCacheAttributes, setDefaultElementAttributes
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, dispose, freeMemoryElements, getCacheAttributes, getDefaultElementAttributes, getStatistics, getStats, setCacheAttributes, setDefaultElementAttributes
public CacheAccess(CompositeCache<K,V> cacheControl)
cacheControl
- The cache which the created instance accessespublic V get(K name)
get
in interface ICacheAccess<K,V>
name
- Key the object is stored aspublic Map<K,V> getMatching(String pattern)
getMatching
in interface ICacheAccess<K,V>
pattern
- - a key pattern for the objects storedpublic ICacheElement<K,V> getCacheElement(K name)
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.
getCacheElement
in interface ICacheAccess<K,V>
name
- Key the Serializable is stored aspublic Map<K,ICacheElement<K,V>> getCacheElements(Set<K> names)
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.
getCacheElements
in interface ICacheAccess<K,V>
names
- set of Serializable cache keyspublic Map<K,ICacheElement<K,V>> getMatchingCacheElements(String pattern)
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.
getMatchingCacheElements
in interface ICacheAccess<K,V>
pattern
- key search patternpublic void putSafe(K key, V value)
putSafe
in interface ICacheAccess<K,V>
key
- Key object will be stored withvalue
- Object to storeCacheException
- and ObjectExistsException is thrown if the item is already in the
cache.public void put(K name, V obj)
put
in interface ICacheAccess<K,V>
name
- Key object will be stored withobj
- Object to storepublic void put(K key, V val, IElementAttributes attr)
If the key or the value is null, and InvalidArgumentException is thrown.
put
in interface ICacheAccess<K,V>
ICacheAccess.put(Object, Object, IElementAttributes)
public void remove(K name)
remove
in interface ICacheAccess<K,V>
name
- the name of the item to remove.public void resetElementAttributes(K name, IElementAttributes attr)
resetElementAttributes
in interface ICacheAccess<K,V>
name
- Key of object to reset attributes forattr
- New attributes for the objectInvalidHandleException
- if the item does not exist.public IElementAttributes getElementAttributes(K name)
getElementAttributes
in interface ICacheAccess<K,V>
name
- Key of object to get attributes forCopyright © 2002–2018 The Apache Software Foundation. All rights reserved.