|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jcs.access.CacheAccess
This class provides an interface for all types of access to the cache.
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 items wrapper, the element configuration, put an item in the cache, remove an item, and clear a region.
The JCS class is the prefered way to access these methods.
Field Summary | |
protected CompositeCache |
cacheControl
The cache that a given instance of this class provides access to. |
Constructor Summary | |
CacheAccess(CompositeCache cacheControl)
Constructor for the CacheAccess object. |
Method Summary | |
void |
clear()
Removes all of the elements from a region. |
static CacheAccess |
defineRegion(java.lang.String name)
Define a new cache region with the given name. |
static CacheAccess |
defineRegion(java.lang.String name,
CompositeCacheAttributes cattr)
Define a new cache region with the specified name and attributes. |
static CacheAccess |
defineRegion(java.lang.String name,
CompositeCacheAttributes cattr,
IElementAttributes attr)
Define a new cache region with the specified name and attributes and return a CacheAccess to it. |
void |
destroy()
Deprecated. |
void |
destroy(java.lang.Object name)
Deprecated. use remove |
void |
dispose()
Dispose this region. |
protected static void |
ensureCacheManager()
Helper method which checks to make sure the cacheMgr class field is set, and if not requests an instance from CacheManagerFactory. |
java.lang.Object |
get(java.lang.Object name)
Retrieve an object from the cache region this instance provides access to. |
static CacheAccess |
getAccess(java.lang.String region)
Get a CacheAccess instance for the given region. |
static CacheAccess |
getAccess(java.lang.String region,
ICompositeCacheAttributes icca)
Get a CacheAccess instance for the given region with the given attributes. |
ICompositeCacheAttributes |
getCacheAttributes()
Gets the ICompositeCacheAttributes of the cache region |
ICacheElement |
getCacheElement(java.lang.Object name)
This method returns the ICacheElement wrapper which provides access to element info and other attributes. |
IElementAttributes |
getElementAttributes()
GetElementAttributes will return an attribute object describing the current attributes associated with the object name. |
IElementAttributes |
getElementAttributes(java.lang.Object name)
GetElementAttributes will return an attribute object describing the current attributes associated with the object name. |
ICacheStats |
getStatistics()
This returns the ICacheStats object with information on this region and its auxiliaries. |
java.lang.String |
getStats()
|
void |
put(java.lang.Object name,
java.lang.Object obj)
Place a new object in the cache, associated with key name. |
void |
put(java.lang.Object key,
java.lang.Object val,
IElementAttributes attr)
Description of the Method |
void |
putSafe(java.lang.Object key,
java.lang.Object value)
Place a new object in the cache, associated with key name. |
void |
remove()
Deprecated. use clear() |
void |
remove(java.lang.Object name)
Removes a single item by name. |
void |
resetElementAttributes(IElementAttributes attr)
ResetAttributes allows for some of the attributes of a region to be reset in particular expiration time attriubtes, time to live, default time to live and idle time, and event handlers. |
void |
resetElementAttributes(java.lang.Object name,
IElementAttributes attr)
Reset attributes for a particular element in the cache. |
void |
save()
If there are any auxiliary caches associated with this cache, save all objects to them. |
void |
setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the ICompositeCacheAttributes of the cache region. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected CompositeCache cacheControl
Constructor Detail |
public CacheAccess(CompositeCache cacheControl)
cacheControl
- The cache which the created instance accessesMethod Detail |
public static CacheAccess defineRegion(java.lang.String name) throws CacheException
name
- Name that will identify the region
CacheException
public static CacheAccess defineRegion(java.lang.String name, CompositeCacheAttributes cattr) throws CacheException
name
- Name that will identify the regioncattr
- CompositeCacheAttributes for the region
CacheException
public static CacheAccess defineRegion(java.lang.String name, CompositeCacheAttributes cattr, IElementAttributes attr) throws CacheException
name
- Name that will identify the regioncattr
- CompositeCacheAttributes for the regionattr
- Attributes for the region
CacheException
public static CacheAccess getAccess(java.lang.String region) throws CacheException
region
- Name that identifies the region
CacheException
public static CacheAccess getAccess(java.lang.String region, ICompositeCacheAttributes icca) throws CacheException
region
- Name that identifies the regionicca
-
CacheException
protected static void ensureCacheManager()
public java.lang.Object get(java.lang.Object name)
get
in interface ICacheAccess
name
- Key the object is stored as
public ICacheElement getCacheElement(java.lang.Object 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 teh ElementAttributes should be current.
name
- Key the object is stored as
public void putSafe(java.lang.Object key, java.lang.Object value) throws CacheException
putSafe
in interface ICacheAccess
key
- Key object will be stored withvalue
- Object to store
CacheException
public void put(java.lang.Object name, java.lang.Object obj) throws CacheException
put
in interface ICacheAccess
name
- Key object will be stored withobj
- Object to store
CacheException
public void put(java.lang.Object key, java.lang.Object val, IElementAttributes attr) throws CacheException
ICacheAccess
put
in interface ICacheAccess
key
- val
- attr
-
CacheException
public void destroy() throws CacheException
destroy
in interface ICacheAccess
CacheException
ICacheAccess.remove()
public void remove() throws CacheException
remove
in interface ICacheAccess
CacheException
public void clear() throws CacheException
CacheException
public void destroy(java.lang.Object name) throws CacheException
destroy
in interface ICacheAccess
name
- Key that specifies object to invalidate
CacheException
ICacheAccess.remove()
public void remove(java.lang.Object name) throws CacheException
remove
in interface ICacheAccess
name
-
CacheException
public void save()
This is mainly a testing method. Dispose should do what you want on shutdown in a safer manner.
public void resetElementAttributes(IElementAttributes attr) throws CacheException, InvalidHandleException
resetElementAttributes
in interface ICacheAccess
attr
- New attributes for this region.
CacheException
InvalidHandleException
public void resetElementAttributes(java.lang.Object name, IElementAttributes attr) throws CacheException, InvalidHandleException
resetElementAttributes
in interface ICacheAccess
name
- Key of object to reset attributes forattr
- New attributes for the object
CacheException
InvalidHandleException
public IElementAttributes getElementAttributes() throws CacheException
getElementAttributes
in interface ICacheAccess
CacheException
public IElementAttributes getElementAttributes(java.lang.Object name) throws CacheException
getElementAttributes
in interface ICacheAccess
name
- Key of object to get attributes for
CacheException
public ICacheStats getStatistics()
This data can be formatted as needed.
public java.lang.String getStats()
public void dispose()
To simply remove all elements from the region use clear().
public ICompositeCacheAttributes getCacheAttributes()
getCacheAttributes
in interface ICacheAccess
public void setCacheAttributes(ICompositeCacheAttributes cattr)
setCacheAttributes
in interface ICacheAccess
cattr
- The new ICompositeCacheAttribute value
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |