| |
|
| java.lang.Object com.opensymphony.oscache.base.CacheEntry
CacheEntry | public class CacheEntry implements Serializable(Code) | | 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.
version: $Revision: 388 $ author: Mike Cannon-Brookes author: Todd Gochenour author: Francois Beauregard |
Field Summary | |
final public static int | INDEFINITE_EXPIRY Specifying this as the refresh period for the
CacheEntry.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 | |
public | CacheEntry(String key) Construct a new CacheEntry using the key provided. | public | CacheEntry(String key, EntryRefreshPolicy policy) Construct a CacheEntry.
Parameters: key - The unique key for this CacheEntry . Parameters: policy - Object that implements refresh policy logic. | public | CacheEntry(String key, EntryRefreshPolicy policy, String[] groups) Construct a CacheEntry.
Parameters: key - The unique key for this CacheEntry . Parameters: policy - The object that implements the refresh policy logic. |
Method Summary | |
public void | flush() Flush the entry from cache. | public Object | getContent() Get the cached content from this CacheEntry. | public long | getCreated() Get the date this CacheEntry was created. | public Set | getGroups() Gets the cache groups that this cache entry belongs to. | public String | getKey() | public long | getLastUpdate() Get the date this CacheEntry was last updated. | public int | getSize() Get the size of the cache entry in bytes (roughly).
Currently this method only handles Strings and
ResponseContent objects. | public boolean | isNew() Indicates whether this CacheEntry is a freshly created one and
has not yet been assigned content or placed in a cache. | public boolean | needsRefresh(int refreshPeriod) Check if this CacheEntry needs to be refreshed.
Parameters: refreshPeriod - The period of refresh (in seconds). | public synchronized void | setContent(Object value) Sets the actual content that is being cached. | public synchronized void | setGroups(String[] groups) Sets the cache groups for this entry. | public synchronized void | setGroups(Collection groups) | public void | setLastUpdate(long update) Set the date this CacheEntry was last updated. |
INDEFINITE_EXPIRY | final public static int INDEFINITE_EXPIRY(Code) | | Specifying this as the refresh period for the
CacheEntry.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.
|
CacheEntry | public CacheEntry(String key)(Code) | | Construct a new CacheEntry using the key provided.
Parameters: key - The key of this CacheEntry |
CacheEntry | public CacheEntry(String key, EntryRefreshPolicy policy)(Code) | | Construct a CacheEntry.
Parameters: key - The unique key for this CacheEntry . Parameters: policy - Object that implements refresh policy logic. This parameteris optional. |
CacheEntry | public CacheEntry(String key, EntryRefreshPolicy policy, String[] groups)(Code) | | Construct a CacheEntry.
Parameters: key - The unique key for this CacheEntry . Parameters: policy - The object that implements the refresh policy logic. Thisparameter is optional. Parameters: groups - The groups that this CacheEntry belongs to. Thisparameter is optional. |
flush | public void flush()(Code) | | Flush the entry from cache.
note that flushing the cache doesn't actually remove the cache contents
it just tells the CacheEntry that it needs a refresh next time it is asked
this is so that the content is still there for a .
|
getContent | public Object getContent()(Code) | | Get the cached content from this CacheEntry.
The content of this CacheEntry. |
getCreated | public long getCreated()(Code) | | Get the date this CacheEntry was created.
The date this CacheEntry was created. |
getGroups | public Set getGroups()(Code) | | Gets the cache groups that this cache entry belongs to.
These returned groups should be treated as immuatable.
A set containing the names of all the groups thatthis cache entry belongs to. |
getKey | public String getKey()(Code) | | Get the key of this CacheEntry
The key of this CacheEntry |
getLastUpdate | public long getLastUpdate()(Code) | | Get the date this CacheEntry was last updated.
The date this CacheEntry was last updated. |
getSize | public int getSize()(Code) | | Get the size of the cache entry in bytes (roughly).
Currently this method only handles Strings and
ResponseContent objects.
The approximate size of the entry in bytes, or -1 if thesize could not be estimated. |
isNew | public boolean isNew()(Code) | | Indicates whether this CacheEntry is a freshly created one and
has not yet been assigned content or placed in a cache.
true if this entry is newly created |
needsRefresh | public boolean needsRefresh(int refreshPeriod)(Code) | | Check if this CacheEntry needs to be refreshed.
Parameters: refreshPeriod - The period of refresh (in seconds). Passing inCacheEntry.INDEFINITE_EXPIRY will result in the content never becomingstale unless it is explicitly flushed, or expired by a customEntryRefreshPolicy. Passing in 0 will always result in arefresh being required. Whether or not this CacheEntry needs refreshing. |
setContent | public synchronized void setContent(Object value)(Code) | | Sets the actual content that is being cached. Wherever possible this
object should be 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.
Parameters: value - The content to store in this CacheEntry. |
setGroups | public synchronized void setGroups(String[] groups)(Code) | | Sets the cache groups for this entry.
Parameters: groups - A string array containing all the group names |
setGroups | public synchronized void setGroups(Collection groups)(Code) | | Sets the cache groups for this entry
Parameters: groups - A collection containing all the group names |
setLastUpdate | public void setLastUpdate(long update)(Code) | | Set the date this CacheEntry was last updated.
Parameters: update - The time (in milliseconds) this CacheEntry was last updated. |
|
|
|