Package org.apache.fulcrum.cache
Class CachedObject<T>
- java.lang.Object
- 
- org.apache.fulcrum.cache.CachedObject<T>
 
- 
- All Implemented Interfaces:
- Serializable
 - Direct Known Subclasses:
- RefreshableCachedObject
 
 public class CachedObject<T> extends Object implements Serializable Wrapper for an object you want to store in a cache for a period of time.- Version:
- $Id: CachedObject.java 1890338 2021-05-31 10:31:19Z gk $
- Author:
- Dave Bryson, Henning P. Schmiedehausen, Eric Pugh
- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description CachedObject(T object)Constructor; sets the object to expire in the default time (30 minutes).CachedObject(T object, long expires)Constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetContents()Returns the cached object.longgetCreated()Returns the creation time for the object.longgetExpires()Returns the expiration time for the object.booleanisStale()Is the object stale?voidsetExpires(long expires)Set the expiration interval for the object.voidsetStale(boolean stale)Set the stale status for the object.
 
- 
- 
- 
Field Detail- 
DEFAULTpublic static final int DEFAULT Cache the object with the Default TTL- See Also:
- Constant Field Values
 
 - 
FOREVERpublic static final int FOREVER Do not expire the object- See Also:
- Constant Field Values
 
 - 
createdprotected long created When the object is created.
 
- 
 - 
Constructor Detail- 
CachedObjectpublic CachedObject(T object) Constructor; sets the object to expire in the default time (30 minutes).- Parameters:
- object- The object you want to cache.
 
 - 
CachedObjectpublic CachedObject(T object, long expires) Constructor.- Parameters:
- object- The object to cache.
- expires- How long before the object expires, in ms, e.g. 1000 = 1 second.
 
 
- 
 - 
Method Detail- 
getContentspublic T getContents() Returns the cached object.- Returns:
- The cached object.
 
 - 
getCreatedpublic long getCreated() Returns the creation time for the object.- Returns:
- When the object was created.
 
 - 
getExpirespublic long getExpires() Returns the expiration time for the object.- Returns:
- When the object expires.
 
 - 
setExpirespublic void setExpires(long expires) Set the expiration interval for the object.- Parameters:
- expires- Expiration interval in millis ( 1 second = 1000 millis)
 
 - 
setStalepublic void setStale(boolean stale) Set the stale status for the object.- Parameters:
- stale- Whether the object is stale or not.
 
 - 
isStalepublic boolean isStale() Is the object stale?- Returns:
- True if the object is stale.
 
 
- 
 
-