Invalidating entries in a servlet cache

Use this task to invalidate a cache entry from a servlet cache instance.

Before you begin

Enable the dynamic cache service, servlet caching and develop the cachespec.xml.

About this task

After a servlet is invoked and completes generating the output to cache, a cache entry is created that contains the output and the side effects of the servlet. Perform this task so that your application can invalidate a cache entry from a servlet cache.

Procedure

  1. Enable the dynamic cache service, servlet caching, and develop the cachespec.xml.
  2. Build the application to access the servlet cache and invalidate a cache entry.
     import com.ibm.websphere.cache.ServletCache;
     import com.ibm.websphere.cache.DynamicCacheAccessor;
     
    	// obtain reference to the servlet cache instance using the cache instances jndi name
      	   ServletCache cache = DynamicCacheAccessor.getServletCacheInstance("services/cache/basecache");
    	// invalidate the cache entry using the cache ID generated as defined by the cache policy in the cachespec.xml
      	   cache.invalidateById("/dynacachetests/TimeStamp:arg1=yes:requestType=GET", true);
  3. Deploy the application.

Icon that indicates the type of topic Task topic



Timestamp icon Last updated: March 5, 2017 17:27
File name: tdyn_invalidatesc.html