|
|||||||||||
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,
ICompositeCacheAttributes cattr)
Define a new cache region with the specified name and attributes. |
static CacheAccess |
defineRegion(java.lang.String name,
ICompositeCacheAttributes 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 |
getDefaultElementAttributes()
Retrieves the default element attributes used by this region. |
IElementAttributes |
getElementAttributes()
Deprecated. As of release 1.3 |
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)
Deprecated. As of release 1.3 |
void |
resetElementAttributes(java.lang.Object name,
IElementAttributes attr)
Reset attributes for a particular element in the cache. |
void |
setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the ICompositeCacheAttributes of the cache region. |
void |
setDefaultElementAttributes(IElementAttributes attr)
This method is does not reset the attributes for items already in the cache. |
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, ICompositeCacheAttributes cattr) throws CacheException
name
- Name that will identify the regioncattr
- CompositeCacheAttributes for the region
CacheException
public static CacheAccess defineRegion(java.lang.String name, ICompositeCacheAttributes 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 resetElementAttributes(IElementAttributes attr) throws CacheException, InvalidHandleException
resetElementAttributes
in interface ICacheAccess
attr
- New attributes for this region.
CacheException
InvalidHandleException
setDefaultElementAttributes
public void setDefaultElementAttributes(IElementAttributes attr) throws CacheException
attr
- the default attributes.
CacheException
- if something goes wrong.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
- if the item does not exist.public IElementAttributes getElementAttributes() throws CacheException
This was confusing, so I created a new method with a clear name.
getElementAttributes
in interface ICacheAccess
CacheException
getDefaultElementAttributes
public IElementAttributes getDefaultElementAttributes() throws CacheException
Each time an element is added to the cache without element attributes, the default element attributes are cloned.
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 |