package com.sybase.jaguar.servlet; public class CacheManager
Allows you to cache responses or parts of a response in Java servlets.
None. Call the CacheManager.getInstance(ServletContext) method.
Gets the instance of the CacheManager for a given servlet context. Each context has a single CacheManager instance.
Package |
com.sybase.jaguar.servlet |
Class |
CacheManager |
public static CacheManager getInstance(ServletContext context)
The servlet context.
The CacheManager instance for the context, or null if the specified context is not a valid EAServer servlet context.
Creates a new cache.
Package |
com.sybase.jaguar.servlet |
Class |
CacheManager |
public void createCache(String cacheName, String nameSpace, String size) throws CacheNameException
The name of the cache to create. The method throws CacheNameException if the name is invalid.
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.
The cache size, specified as a string using either Mb for megabytes or Kb for kilobytes, for example “10Mb” means 10 megabytes.
Retrieves data from the cache.
Package |
com.sybase.jaguar.servlet |
Class |
CacheManager |
public String getData(String cacheName, PageCacheKey key) throws CacheNotFoundException, CacheNameException
The name of the cache to use.
The key for the entry. Call getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int) to get a key instance.
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.
Places data in the cache.
Package |
com.sybase.jaguar.servlet |
Class |
CacheManager |
public void putData(String cacheName, PageCacheKey key, String data, int timeout) throws CacheNotFoundException, CacheNameException
The name of the cache to use.
The key for the entry. Call getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int) to get a key instance.
The text to cache.
The timeout for the entry, in seconds.
Flushes the entry for the specified key from the cache.
Package |
com.sybase.jaguar.servlet |
Class |
CacheManager |
public void flushCache(String cacheName, PageCacheKey key) throws CacheNotFoundException, CacheNameException
The name of the cache to flush from.
The key for the entry to flush. Call getCacheKey(HttpServletRequest, String, String, String, String, String, boolean, int) to get a key instance.
Flushes caches associated with the specified scope.
Package |
com.sybase.jaguar.servlet |
Class |
CacheManager |
public void flushCacheByScope(HttpServletRequest request, String scope)
The request associated with the page that you are caching content for.
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. |
Creates a cache key for the specified inputs.
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)
The request associated with the page that you are caching content for.
A comma-separated list of request parameters to include in the key. Specify “*” to include all parameters.
A comma-separated list of session attributes to include in the key. Specify “*” to include all attributes.
A comma-separated list of request headers to include in the key. Pass as null to omit all headers from the key.
A comma-separated list of message topics to include in the key. Pass as null to omit all headers from the key.
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. |
Pass as true if locale-sensitive headers are to be included in the key, and false otherwise.
A string containing the unique tag ID for the tag.
A com.sybase.jaguar.servlet.PageCacheKey instance containing the input data.
Copyright © 2005. Sybase Inc. All rights reserved. |