Class CacheManager

Description

package com.sybase.jaguar.servlet;
public class CacheManager

Allows you to cache responses or parts of a response in Java servlets.

Constructors

None. Call the CacheManager.getInstance(ServletContext) method.




CacheManager.getInstance(ServletContext)

Description

Gets the instance of the CacheManager for a given servlet context. Each context has a single CacheManager instance.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public static CacheManager getInstance(ServletContext context)

Parameters

context

The servlet context.

Returns

The CacheManager instance for the context, or null if the specified context is not a valid EAServer servlet context.




CacheManager.createCache(String, String, String)

Description

Creates a new cache.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public void createCache(String cacheName, String nameSpace, String size) throws CacheNameException

Parameters

cacheName

The name of the cache to create. The method throws CacheNameException if the name is invalid.

nameSpace

Specifies what name space the cache is part of. Caches in the same name space share the same MRU/LRU chains so that when an entry is evicted, it evicts the least recently used in all the caches in the same namespace. If you pass as null, the cache is in the default name space.

size

The cache size, specified as a string using either Mb for megabytes or Kb for kilobytes, for example “10Mb” means 10 megabytes.




CacheManager.getData(String, PageCacheKey)

Description

Retrieves data from the cache.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public String getData(String cacheName, PageCacheKey key)
throws CacheNotFoundException, CacheNameException

Parameters

cacheName

The name of the cache to use.

key

The key for the entry. Call getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int) to get a key instance.

Returns

The cached text, or null if no entry matches the key. Throws CacheNotFoundException if there is no cache with the specified name. Throws CacheNameException if the name is invalid.




CacheManager.putData(String, PageCacheKey, String, int)

Description

Places data in the cache.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public void putData(String cacheName, PageCacheKey key, String data, int timeout) throws CacheNotFoundException, CacheNameException

Parameters

cacheName

The name of the cache to use.

key

The key for the entry. Call getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int) to get a key instance.

data

The text to cache.

timeout

The timeout for the entry, in seconds.




CacheManager.flushCacheByKey(String, PageCacheKey)

Description

Flushes the entry for the specified key from the cache.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public void flushCache(String cacheName, PageCacheKey key) throws CacheNotFoundException, CacheNameException

Parameters

cacheName

The name of the cache to flush from.

key

The key for the entry to flush. Call getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int) to get a key instance.




CacheManager.flushCacheByScope(HttpServletRequest, String)

Description

Flushes caches associated with the specified scope.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public void flushCacheByScope(HttpServletRequest request, String scope)

Parameters

request

The request associated with the page that you are caching content for.

scope

A value from the following table:

Value

To indicate

application

To flush all caches in the Web application.

session

To flush all caches whose session ID matches the session ID of the current session. If there is not an active session, nothing is flushed.

page

Flush all caches for the specified page.




CacheManager.getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int)

Description

Creates a cache key for the specified inputs.

Syntax

Package

com.sybase.jaguar.servlet

Class

CacheManager

public PageCacheKey getCacheKey(HttpServletRequest request, String parameters, String attributes, String headers, String messageTopics, String scope, Boolean localeSensitive, String tagID)

Parameters

request

The request associated with the page that you are caching content for.

parameters

A comma-separated list of request parameters to include in the key. Specify “*” to include all parameters.

attributes

A comma-separated list of session attributes to include in the key. Specify “*” to include all attributes.

headers

A comma-separated list of request headers to include in the key. Pass as null to omit all headers from the key.

messageTopics

A comma-separated list of message topics to include in the key. Pass as null to omit all headers from the key.

scope

Controls the scope in which data is stored in the cache. Pass a value from the following table:

Value

To indicate

application

All pages in the Web application have access to the cached data.

session

Only requests in the same session can view the cached data.

localeSensitive

Pass as true if locale-sensitive headers are to be included in the key, and false otherwise.

tagID

A string containing the unique tag ID for the tag.

Returns

A com.sybase.jaguar.servlet.PageCacheKey instance containing the input data.