Reputation: 105
Why the following ehcache.xml doesn't allow to clear caches via JMX (the Operations tab is disabled in JVisualVM for MBean for cache management and enabled for cache statistic)? I use spring boot framework and specify ehcache.xml file location via spring.cache.jcache.config property and just use @Cachable spring framework annotation.
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.0.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.0.xsd">
<service>
<jsr107:defaults enable-management="true" enable-statistics="true"/>
</service>
<cache alias="stringCache">
<key-type>java.lang.String</key-type>
<value-type>java.lang.String</value-type>
<heap unit="entries">2000</heap>
</cache>
</config>
Upvotes: 0
Views: 1916
Reputation: 5731
Clearing cache entries is not supported by the JSR-107 specification. Only clearing the statistics is possible. To workaround that, you will have to create your own MBean.
Upvotes: 5