MicroStrategy ONE

Purging the Object Cache for All Projects

The sample code below illustrates how to purge the object cache for all projects in MicroStrategy Intelligence Server.

 // create a WebObjectsFactory instance

 WebObjectsFactory factory = WebObjectsFactory.getInstance();

 

 // Get the cache source object

 CacheSource source = (CacheSource) factory.getMonitorSource(EnumWebMonitorType.WebMonitorTypeCache);

 

 // Set up the flag to obtain browsing information

 source.setLevel(EnumDSSXMLLevelFlags.DssXmlBrowsingLevel);

 

 // Since we only need to get the project DSSID in order to purge its object cache,

 // so we set the incremental fetch setting to the bare minimum

 source.setBlockBegin(1);

 source.setBlockCount(1);

 

 try {

      // Sends the request to Intelligence Server to retrieve cache information

      CacheResults results = source.getCaches();

 

      // Cache are grouped in project level, so we loop through the caches collection

      // to obtain their project DSSID and then purge the object cache immediately

      for (int i = 0; i < results.size(); i++) {

           // Obtain the project DSSID of each caches collection

           Caches projectLevelCaches = results.get(i);

           String projectDSSID = projectLevelCaches.getProjectDSSID();

 

           // Purge the object cache of each project

           source.purgeCache(projectDSSID, EnumDSSXMLPurgeFlag.DssXmlPurgeObjectCache);

      }     

 } catch (WebObjectsAdminException woae) {

          woae.printStackTrace();

 }