org.apache.turbine.services.cache
Class CachedObject

java.lang.Object
  |
  +--org.apache.turbine.services.cache.CachedObject
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RefreshableCachedObject

public class CachedObject
extends java.lang.Object
implements java.io.Serializable

Wrapper for an object you want to store in a cache for a period of time.

Version:
$Id$
Author:
Dave Bryson, Henning P. Schmiedehausen
See Also:
Serialized Form

Field Summary
private  java.lang.Object contents
          The object to be cached.
protected  long created
          When created.
static int DEFAULT
          Cache the object with the Default TTL
private  long defaultage
          Default age (30 minutes).
private  long expires
          When it expires.
static int FOREVER
          Do not expire the object
private  boolean stale
          Is this object stale/expired?
 
Constructor Summary
CachedObject(java.lang.Object o)
          Constructor; sets the object to expire in the default time (30 minutes).
CachedObject(java.lang.Object o, long expires)
          Constructor.
 
Method Summary
 java.lang.Object getContents()
          Returns the cached object.
 long getCreated()
          Returns the creation time for the object.
 long getExpires()
          Returns the expiration time for the object.
 boolean getStale()
          Get the stale status for the object.
 boolean isStale()
          Is the object stale?
 void setStale(boolean stale)
          Set the stale status for the object.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
Cache the object with the Default TTL

FOREVER

public static final int FOREVER
Do not expire the object

contents

private java.lang.Object contents
The object to be cached.

defaultage

private long defaultage
Default age (30 minutes).

created

protected long created
When created.

expires

private long expires
When it expires.

stale

private boolean stale
Is this object stale/expired?
Constructor Detail

CachedObject

public CachedObject(java.lang.Object o)
Constructor; sets the object to expire in the default time (30 minutes).
Parameters:
o - The object you want to cache.

CachedObject

public CachedObject(java.lang.Object o,
                    long expires)
Constructor.
Parameters:
o - The object to cache.
expires - How long before the object expires, in ms, e.g. 1000 = 1 second.
Method Detail

getContents

public java.lang.Object getContents()
Returns the cached object.
Returns:
The cached object.

getCreated

public long getCreated()
Returns the creation time for the object.
Returns:
When the object was created.

getExpires

public long getExpires()
Returns the expiration time for the object.
Returns:
When the object expires.

setStale

public void setStale(boolean stale)
Set the stale status for the object.
Parameters:
stale - Whether the object is stale or not.

getStale

public boolean getStale()
Get the stale status for the object.
Returns:
Whether the object is stale or not.

isStale

public boolean isStale()
Is the object stale?
Returns:
True if the object is stale.


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.