cogClears the page and page exist caches
Developed by

Vincent Massol

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

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

void clearCache(def server, def cacheName)
{
 def query = new ObjectName("org.xwiki.infinispan:name=${cacheName},component=Cache,*")
 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])
 }
}

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

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags:
Created by Vincent Massol on 2020/01/08 19:18
     

Get Connected