Class Cache

  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.droplet.Cache
All Implemented Interfaces:
MessageSink, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class Cache
extends DynamoServlet
implements MessageSink

This droplet caches the contents of its oparam named output. It improves performance for pages that generate dynamic content which is the same for all users, or where there are a small number of versions of the content (for example, one version for members and another for guests).

If your request is rewriting URLs to include the session id, the session id and request id will be removed from the cached content. This prevents session ids from being returned to incorrect users. If you know that the contents of your oparam do not define any URLs and you want to improve the performance of this case by avoiding the search for session ids, you can specify the parameter hasNoURLs to "true".

Your cached content will periodically be regenerated the first request after a specified time interval has elapsed since the content was cached. You can specify what this interval should be with the request parameter cacheCheckSeconds. If no cacheCheckSeconds parameter is supplied, the content is expired using the bean property defaultCacheCheckSeconds on the cache droplet itself.

It is possible to have more than one view of the cached data associated with each cache droplet invocation. For example, if your page had different views for members and non-members, you can still use the cache droplet. To do this, set the key request parameter to contain the a value that uniquely identifies the content of the page. In the above example, we'd set the key parameter to "true" for members and "false" for non-members. The cache droplet maintains separate cached content for each value of the key parameter. You do not need to supply system wide unique key values. Each cache droplet gets its own name space of key values.

All content managed by a single cache droplet instance is periodically purged based on the property purgeCacheSeconds (the default is every 6 hours). This is to retrieve data storage for instances of the cache droplet that are no longer in use. This would happen if you remove or recompile a jhtml page that has a cache droplet.

If you visit the admin page for this component in the component browser, you can see statistics about the content which is cached.

The Cache component itself is a JMS message sink. When it receives a message, it flushes any content that it may define. You can use multiple instance of the Cache servlet bean if you would like to control which content gets flushed for a JMS message.

Field Summary
static java.lang.String CLASS_VERSION
static java.lang.String DO_NOT_CACHE_RESPONSE
static java.lang.String PROTOCOL_CHANGE_DROPLET
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
Fields inherited from class atg.nucleus.servlet.ServletService
Fields inherited from class atg.nucleus.GenericService
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
Constructor Summary
Method Summary
protected  javax.servlet.Servlet createAdminServlet()
          Creates and returns a new Servlet that will administer this service.
 java.lang.String ensureNoIds(DynamoHttpServletRequest pRequest, java.lang.String cacheData)
 void flushCache()
          Forces cache to flush the data.
 char[] getCachedContent(DynamoHttpServletRequest pRequest)
          Returns the cached content for the given request.
 int getDefaultCacheCheckSeconds()
 boolean getEnabled()
 atg.servlet.pagecompile.PageEncodingTyper getEncodingTyper()
 long getPurgeCacheSeconds()
 java.lang.String getSessionURLName()
          The name for the session id.
 void init(javax.servlet.ServletConfig pConfig)
          Initializes the servlet.
 boolean isCachingEnabled(DynamoHttpServletRequest pRequest)
          If this returns false, then the droplet should proceed as if no caching is involved at all.
 void receiveMessage(java.lang.String pPortName, javax.jms.Message pMessage)
          Called by DMS when a Message arrives through the given input port.
 void removeCachedElement(java.lang.String key)
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Determine whether we have a valid cached entry.
 void setCachedContent(DynamoHttpServletRequest pRequest, char[] pContent)
          Sets the cached content for the given request.
 void setDefaultCacheCheckSeconds(int pCheckCacheSeconds)
          This property specifies the default time interval for invalidating cached content if the droplet does not receive the request parameter cacheCheckSeconds.
 void setEnabled(boolean pEnabled)
          Sets the property Enabled.
 void setEncodingTyper(atg.servlet.pagecompile.PageEncodingTyper pEncodingTyper)
          Sets the property EncodingTyper.
 void setPurgeCacheSeconds(long pPurgeCacheSeconds)
          This property specifies the default time interval for purging the entire collection of cached content.
 void setSessionURLName(java.lang.String pSessionURLName)
          The name for the session id.
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, setServletInfo
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
Methods inherited from class atg.nucleus.GenericService
addLogListener, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static java.lang.String CLASS_VERSION


public static final java.lang.String DO_NOT_CACHE_RESPONSE
See Also:
Constant Field Values


public static final java.lang.String PROTOCOL_CHANGE_DROPLET
See Also:
Constant Field Values
Constructor Detail


public Cache()
Method Detail


public void setSessionURLName(java.lang.String pSessionURLName)
The name for the session id. Usually "jsessionid".


public java.lang.String getSessionURLName()
The name for the session id. Usually "jsessionid".


public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
Determine whether we have a valid cached entry. If so, render from the cache, otherwise, render the output parameter, caching the results for rendering the next time.

service in class DynamoServlet
pRequest - the request to be processed
pResponse - the response object for this request
javax.servlet.ServletException - an application specific error occurred processing this request - an error occurred reading data from the request or writing data to the response.


public java.lang.String ensureNoIds(DynamoHttpServletRequest pRequest,
                                    java.lang.String cacheData)


public void removeCachedElement(java.lang.String key)


public void setDefaultCacheCheckSeconds(int pCheckCacheSeconds)
This property specifies the default time interval for invalidating cached content if the droplet does not receive the request parameter cacheCheckSeconds.


public int getDefaultCacheCheckSeconds()


public void setPurgeCacheSeconds(long pPurgeCacheSeconds)
This property specifies the default time interval for purging the entire collection of cached content. This is necessary to free up content associated with pages that are no longer in use by the system (i.e. jhtml pages that have been recompiled).


public long getPurgeCacheSeconds()


public void setEnabled(boolean pEnabled)
Sets the property Enabled. If the servlet is not enabled, the output parameter is sent to the browser without any caching.


public boolean getEnabled()
The value of the property Enabled.


public void flushCache()
Forces cache to flush the data.


public void receiveMessage(java.lang.String pPortName,
                           javax.jms.Message pMessage)
                    throws javax.jms.JMSException
Called by DMS when a Message arrives through the given input port. There may be concurrent calls of this method from multiple Threads.

Specified by:
receiveMessage in interface MessageSink
javax.jms.JMSException - if there is a problem processing the message


public void setEncodingTyper(atg.servlet.pagecompile.PageEncodingTyper pEncodingTyper)
Sets the property EncodingTyper.


public atg.servlet.pagecompile.PageEncodingTyper getEncodingTyper()
The value of the property EncodingTyper.


protected javax.servlet.Servlet createAdminServlet()
Creates and returns a new Servlet that will administer this service.

createAdminServlet in class GenericService


public boolean isCachingEnabled(DynamoHttpServletRequest pRequest)
If this returns false, then the droplet should proceed as if no caching is involved at all. This would be false if the enabled property is set to false, or if session tracking is enabled and URL rewriting is happening (and hasNoURLs is not set in the request).


public char[] getCachedContent(DynamoHttpServletRequest pRequest)
Returns the cached content for the given request. The key for the content is a combination of the request URI and the "key" parameter - the "key" parameter must be specified. The optional "cacheCheckSeconds" parameter indicates how long the content should remain in the cache.


public void setCachedContent(DynamoHttpServletRequest pRequest,
                             char[] pContent)
Sets the cached content for the given request. The key for the content is a combination of the request URI and the "key" parameter, which must be specified.


public void init(javax.servlet.ServletConfig pConfig)
          throws javax.servlet.ServletException
Initializes the servlet. This is called automatically by the system when the servlet is first loaded.

Specified by:
init in interface javax.servlet.Servlet
init in class ServletService
pServletConfig - servlet configuration information
javax.servlet.ServletException - if a servlet exception has occurred