public class Cache extends DynamoServlet implements MessageSink
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.
Modifier and Type | Class and Description |
---|---|
protected class |
Cache.CacheDataEntry |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
static java.lang.String |
DO_NOT_CACHE_RESPONSE |
static java.lang.String |
PROTOCOL_CHANGE_DROPLET |
mAllowCleanupRequest, mParameters
SERVLET_INFO_KEY
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
protected javax.servlet.Servlet |
createAdminServlet()
Creates and returns a new Servlet that will administer this service.
|
protected java.util.Map<java.lang.Object,Cache.CacheDataEntry> |
createMap()
Create the map to be used as storage for the cache.
|
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.
|
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
destroy, getServletConfig, getServletInfo, setServletInfo
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
addLogListener, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, 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, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService, toString
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
public static final java.lang.String DO_NOT_CACHE_RESPONSE
public static final java.lang.String PROTOCOL_CHANGE_DROPLET
public void setSessionURLName(java.lang.String pSessionURLName)
public java.lang.String getSessionURLName()
public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
service
in class DynamoServlet
pRequest
- the request to be processedpResponse
- the response object for this requestjavax.servlet.ServletException
- an application specific error occurred
processing this requestjava.io.IOException
- 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)
public int getDefaultCacheCheckSeconds()
public void setPurgeCacheSeconds(long pPurgeCacheSeconds)
public long getPurgeCacheSeconds()
public void setEnabled(boolean pEnabled)
public boolean getEnabled()
public void flushCache()
public void receiveMessage(java.lang.String pPortName, javax.jms.Message pMessage) throws javax.jms.JMSException
receiveMessage
in interface MessageSink
javax.jms.JMSException
- if there is a problem processing the
messagepublic void setEncodingTyper(atg.servlet.pagecompile.PageEncodingTyper pEncodingTyper)
public atg.servlet.pagecompile.PageEncodingTyper getEncodingTyper()
protected javax.servlet.Servlet createAdminServlet()
createAdminServlet
in class GenericService
public boolean isCachingEnabled(DynamoHttpServletRequest pRequest)
public char[] getCachedContent(DynamoHttpServletRequest pRequest)
public void setCachedContent(DynamoHttpServletRequest pRequest, char[] pContent)
public void init(javax.servlet.ServletConfig pConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class DynamoServlet
pServletConfig
- servlet configuration informationjavax.servlet.ServletException
- if a servlet exception has occurredprotected java.util.Map<java.lang.Object,Cache.CacheDataEntry> createMap()
Note that createMap() is called by the constructor, so property configuration may not be complete.