cogClears the page and page exist caches
Type
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

{{groovy}}
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;

void clearCache(def server, def cacheName)
{
 def objectName = "org.xwiki.infinispan:name=${cacheName},component=Cache,*"
 def query = new ObjectName(objectName)
 def names = server.queryNames(query, null)
 if (!names.isEmpty()) {
   def name = names.iterator().next()
   def mbean = new GroovyMBean(server, name)
    mbean.invokeMethod('clear', new Object[0])
 } else {
    println "Object [{{{${objectName}}}}] not found in JMX server"
 }
}

MBeanServer server = ManagementFactory.getPlatformMBeanServer();
clearCache(server, '"xwiki.store.pagecache(local)"')
clearCache(server, '"xwiki.store.pageexistcache(local)"')
{{/groovy}}
Tags:
     

Get Connected