FileDocCategorySizeDatePackage
CacheEntry.javaAPI DocGlassfish v2 API3522Fri May 04 22:35:28 BST 2007com.sun.appserv.web.taglibs.cache

CacheEntry

public class CacheEntry extends Object
Class responsible for caching and expiring the execution result of a JSP fragment.

Fields Summary
public static final int
NO_TIMEOUT
String
content
volatile long
expireTime
Constructors Summary
public CacheEntry(String response, int timeout)
Constructs a CacheEntry using the response string to be cached and the timeout after which the entry will expire

 

                            
         
        content = response; 
        computeExpireTime(timeout);  
    
Methods Summary
public voidclear()
clear the contents

        content = null;
        expireTime = 0L;
    
public voidcomputeExpireTime(int timeout)
compute when this entry to be expired based on timeout relative to current time.

param
timeout in seconds

        // timeout is relative to current time
        this.expireTime = (timeout == NO_TIMEOUT) ? timeout :
                          System.currentTimeMillis() + (timeout * 1000);
    
public java.lang.StringgetContent()
Gets the cached content.

return
The cached content

        return this.content;
    
public booleanisValid()
is this response still valid?

        return (expireTime > System.currentTimeMillis() ||
                expireTime == NO_TIMEOUT);
    
public voidsetExpireTime(long expireTime)
set the real expire time

param
expireTime in milli seconds

        this.expireTime = expireTime;