|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.oscache.base.CacheEntry
A CacheEntry instance represents one entry in the cache. It holds the object that is being cached, along with a host of information about that entry such as the cache key, the time it was cached, whether the entry has been flushed or not and the groups it belongs to.
Field Summary | |
static int |
INDEFINITE_EXPIRY
Specifying this as the refresh period for the needsRefresh(int) method will ensure
an entry does not become stale until it is
either explicitly flushed or a custom refresh
policy causes the entry to expire. |
Constructor Summary | |
CacheEntry(java.lang.String key)
Construct a new CacheEntry using the key provided. |
|
CacheEntry(java.lang.String key,
EntryRefreshPolicy policy)
Construct a CacheEntry. |
|
CacheEntry(java.lang.String key,
EntryRefreshPolicy policy,
java.lang.String[] groups)
Construct a CacheEntry. |
Method Summary | |
void |
flush()
Flush the entry from cache. |
java.lang.Object |
getContent()
Get the cached content from this CacheEntry. |
long |
getCreated()
Get the date this CacheEntry was created. |
java.util.Set |
getGroups()
Gets the cache groups that this cache entry belongs to. |
java.lang.String |
getKey()
Get the key of this CacheEntry |
long |
getLastUpdate()
Get the date this CacheEntry was last updated. |
int |
getSize()
Get the size of the cache entry in bytes (roughly). |
boolean |
isNew()
Indicates whether this CacheEntry is a freshly created one and has not yet been assigned content or placed in a cache. |
boolean |
needsRefresh(int refreshPeriod)
Check if this CacheEntry needs to be refreshed. |
void |
setContent(java.lang.Object value)
Sets the actual content that is being cached. |
void |
setGroups(java.util.Collection groups)
Sets the cache groups for this entry |
void |
setGroups(java.lang.String[] groups)
Sets the cache groups for this entry. |
void |
setLastUpdate(long update)
Set the date this CacheEntry was last updated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int INDEFINITE_EXPIRY
needsRefresh(int)
method will ensure
an entry does not become stale until it is
either explicitly flushed or a custom refresh
policy causes the entry to expire.
Constructor Detail |
public CacheEntry(java.lang.String key)
key
- The key of this CacheEntrypublic CacheEntry(java.lang.String key, EntryRefreshPolicy policy)
key
- The unique key for this CacheEntry
.policy
- Object that implements refresh policy logic. This parameter
is optional.public CacheEntry(java.lang.String key, EntryRefreshPolicy policy, java.lang.String[] groups)
key
- The unique key for this CacheEntry
.policy
- The object that implements the refresh policy logic. This
parameter is optional.groups
- The groups that this CacheEntry
belongs to. This
parameter is optional.Method Detail |
public void setContent(java.lang.Object value)
Serializable
, however it is not an
absolute requirement when using a memory-only cache. Being Serializable
allows PersistenceListener
s to serialize the cache entries to disk
or database.
value
- The content to store in this CacheEntry.public java.lang.Object getContent()
public long getCreated()
public void setGroups(java.lang.String[] groups)
groups
- A string array containing all the group namespublic void setGroups(java.util.Collection groups)
groups
- A collection containing all the group namespublic java.util.Set getGroups()
public java.lang.String getKey()
public void setLastUpdate(long update)
update
- The time (in milliseconds) this CacheEntry was last updated.public long getLastUpdate()
public boolean isNew()
true
if this entry is newly createdpublic int getSize()
Currently this method only handles
String
s and
ResponseContent
objects.
public void flush()
public boolean needsRefresh(int refreshPeriod)
refreshPeriod
- The period of refresh (in seconds). Passing in
INDEFINITE_EXPIRY
will result in the content never becoming
stale unless it is explicitly flushed, or expired by a custom
EntryRefreshPolicy
. Passing in 0 will always result in a
refresh being required.
|
See www.opensymphony.com for more information. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |