Clearing All - portal dynacaches (DistributedMap) with one click

IBM Dyna Cache Monitor is best way to monitor the any dynacache instances (at WAS level). Most of the time when you access the portal page (with WCM portlet on it or not) portal generate entries in multiple cache objects ( i.e like user information goes into different cache object, portlet related goes into different, and portal page related stuff goes into different cache object..etc). 

During the development it may be very annoying to go to individual caches and clear those to make sure you are seeing proper(updated) content. (Note: Some of portal/wcm caches gets cleared automatically when you change but not all).

We can clear all caches with single click by injecting the below small piece of code into the Cache Monitor JSP (WebSphere\wp_profile\installedApps\sivapcCell\Dynamic Cache Monitor.ear\CacheMonitor.war\selectInstance.jsp)

    <form name="clearAll" method="get" action="selectInstance.jsp">
        <input type="hidden" name="clearAll" value="true">
        <input type="submit" value="Clear All" class="buttons">
    if (request.getParameter("clearAll") != null
        && request.getParameter("clearAll").equals("true")) {
            out.println("<script> var msg = 'Clearing All caches....\\n';");
            Cache tempCache = null;
            String cacheName = "";
            java.util.ListIterator cacheIterator = configuredInstances.listIterator();
            while (cacheIterator.hasNext()) {
                cacheName = (String);
                tempCache = CacheMonitor.getCache(cacheName);
                out.print("msg = msg + 'Clearing-Cache:::"+cacheName.toString() +"\\n';");

Didn't want to make any fancy UI changes , so "Clear All" button looks like below

Once you click on , you will see javascript alert as below.

  1. It is not IBM recommended* way , just came up with this to make my development process simple. 
  2. No guarantees with future version of cache monitor implementations (Tested with latest cachemonitor available as of today, installed on Portal 8/7)


1. Visit below link for Download, Install & Update instructions for DynaCache Monitor.

No comments:

Post a Comment