Sun GlassFish Enterprise Server 2.1 Application Deployment Guide

cache

Configures caching for web application components.

Superelements

sun-web-app (sun-web.xml)

Subelements

The following table describes subelements for the cache element.

Table A–9 cache Subelements

Element 

Required 

Description 

cache-helper

zero or more 

Specifies a custom class that implements the CacheHelper interface.

default-helper

zero or one 

Allows you to change the properties of the default, built-in cache-helper class.

property (with attributes)

zero or more 

Specifies a cache property, which has a name and a value. 

cache-mapping

zero or more 

Maps a URL pattern or a servlet name to its cacheability constraints. 

Attributes

The following table describes attributes for the cache element.

Table A–10 cache Attributes

Attribute 

Default 

Description 

max-entries

4096

(optional) Specifies the maximum number of entries the cache can contain. Must be a positive integer. 

timeout-in-seconds

30

(optional) Specifies the maximum amount of time in seconds that an entry can remain in the cache after it is created or refreshed. Can be overridden by a timeout element.

enabled

true

(optional) Determines whether servlet and JSP caching is enabled. 

Properties

The following table describes properties for the cache element.

Table A–11 cache Properties

Property 

Default 

Description 

cacheClassName

com.sun.appserv.web.cache.LruCache

Specifies the fully qualified name of the class that implements the cache functionality. See Cache Class Names for possible values.

MultiLRUSegmentSize

4096

Specifies the number of entries in a segment of the cache table that should have its own LRU (least recently used) list. Applicable only if cacheClassName is set to com.sun.appserv.web.cache.MultiLruCache.

MaxSize

unlimited; Long.MAX_VALUE

Specifies an upper bound on the cache memory size in bytes (KB or MB units). Example values are 32 KB or 2 MB. Applicable only if cacheClassName is set to com.sun.appserv.web.cache.BoundedMultiLruCache.

Cache Class Names

The following table lists possible values of the cacheClassName property.

Table A–12 cacheClassName Values

Value 

Description 

com.sun.appserv.web.cache.LruCache

A bounded cache with an LRU (least recently used) cache replacement policy. 

com.sun.appserv.web.cache.BaseCache

An unbounded cache suitable if the maximum number of entries is known. 

com.sun.appserv.web.cache.MultiLruCache

A cache suitable for a large number of entries (>4096). Uses the MultiLRUSegmentSize property.

com.sun.appserv.web.cache.BoundedMultiLruCache

A cache suitable for limiting the cache size by memory rather than number of entries. Uses the MaxSize property.