com.go.teaservlet
Class RegionCachingApplication

java.lang.Object
  |
  +--com.go.teaservlet.RegionCachingApplication
All Implemented Interfaces:
AdminApp, Application

public class RegionCachingApplication
extends java.lang.Object
implements AdminApp

Application that defines a cache function for templates. The cache is applied over a region within a template and is called like:

 cache() {
     // Cached template code and text goes here
 }
 
The contents within the cache are used up to a configurable time-to-live value, specified in milliseconds. A specific TTL value can be passed as an argument to the cache function, in order to override the configured default.

Regions are keyed on enclosing template, region number, and HTTP query parameters. An optional secondary key may be passed in which helps to further identify the region. To pass in multiple values for the secondary key, pass in an array.

The cache function can be invoked multiple times within a template and the cache calls can be nested within each other. When templates are reloaded, the cached regions are dropped.

The RegionCachingApplication can also compress cached regions and send the GZIP compressed response to the client. The intention is not to reduce memory usage on the server, but to conserve bandwidth. If the client supports GZIP encoding, then it is eligible to receive a fully or partially GZIP compressed response.

If provided with cluster configuration information to pass along to the ClusterManager, status information may be shared between machines to compare cache sizes.

Version:
36 , 01/07/05
Author:
Brian S O'Neill

Inner Class Summary
static interface RegionCachingApplication.ClusterCacheInfo
           
 class RegionCachingApplication.ClusterCacheInfoImpl
           
 class RegionCachingApplication.RegionCacheInfo
          At the moment this class just contains a single int, but this may change as the application evolves.
 
Constructor Summary
RegionCachingApplication()
           
 
Method Summary
 java.lang.Object createContext(ApplicationRequest request, ApplicationResponse response)
          Returns an instance of RegionCachingContext.
 void destroy()
          Called by the TeaServlet when the application is no longer needed.
 AppAdminLinks getAdminLinks()
           
 java.lang.Class getContextType()
          Returns RegionCachingContext.class.
 void init(ApplicationConfig config)
          Accepts the following optional parameters:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegionCachingApplication

public RegionCachingApplication()
Method Detail

init

public void init(ApplicationConfig config)
          throws javax.servlet.ServletException
Accepts the following optional parameters:
 cache.size   Amount of most recently used cache items to keep, which is
              500 by default.
 default.ttl  Default time-to-live of cached regions, in milliseconds.
              If left unspecified, default.ttl is 5000 milliseconds.
 timeout      Maximum milliseconds to wait on cache before serving an
              expired region. Default value is 500 milliseconds.
 headers      List of headers to use for all keys. i.e. User-Agent or
              Host.
 gzip         Accepts a value from 0 to 9 to set compression level. When
              non-zero, GZIP compression is enabled for cached regions.
              A value of 1 offers fast compression, and a value of 9
              offers best compression. A value of 6 is the typical
              default used by GZIP.

 transactionQueue  Properties for TransactionQueue that executes regions.
    max.threads    Maximum thread count. Default is 100.
    max.size       Maximum size of TransactionQueue. Default is 100.
 
Specified by:
init in interface Application
Following copied from interface: com.go.teaservlet.Application
Parameters:
config - the application's configuration object

destroy

public void destroy()
Description copied from interface: Application
Called by the TeaServlet when the application is no longer needed.
Specified by:
destroy in interface Application

createContext

public java.lang.Object createContext(ApplicationRequest request,
                                      ApplicationResponse response)
Returns an instance of RegionCachingContext.
Specified by:
createContext in interface Application
Following copied from interface: com.go.teaservlet.Application
Parameters:
request - the client's HTTP request
response - the client's HTTP response
Returns:
an object context for the templates

getContextType

public java.lang.Class getContextType()
Returns RegionCachingContext.class.
Specified by:
getContextType in interface Application
Following copied from interface: com.go.teaservlet.Application
Returns:
the class that the createContext method will return

getAdminLinks

public AppAdminLinks getAdminLinks()
Specified by:
getAdminLinks in interface AdminApp