Prev | Home | Next
DynaCache invalidation API
Cache objects are also invalidated programmatically. This is done using the DynamicCacheAccessor object in the DynaCache API.
import com.ibm.websphere.cache.DynamicCacheAccessor; import com.ibm.websphere.cache.DistributedMap; . . . if (DynamicCacheAccessor.isCacheEnabled()) { DistributedMap map = DynamicCacheAccessor.getDistributedMap(); map.invalidate(cacheKey); }In the example, the static method isCacheEnabled() of the DynamicCacheAccessor object is used to find out if caching has been enabled. getDistributedMap() retrieves the cache. The invalidate method using a cacheKey invalidates cache entries. The cacheKey is either a dependency ID or a cache entry ID. If the cacheKey is a dependency ID, then all cache entries having a matching dependency ID are invalidated. If the cacheKey is a cache ID, then only that cache entry is invalidated.
For more information, refer to the WebSphere Application Server v6 Infocenter. Navigate: Reference Æ Developer Æ API Documentation Æ Application programming interfaces. Select com.ibm.websphere.cache to view DynaCache-related APIs including the DynamicCacheAccessor.