首页 文章

带有spring boot的ehCache Statistics

提问于
浏览
1

我有如下ehcache的spring boot应用程序

@Bean
public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() {

    EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
    ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
    //ehCacheManagerFactoryBean.setCacheManagerName("messageCache");
    ehCacheManagerFactoryBean.setShared(true);
    return ehCacheManagerFactoryBean;
}

@Bean
public EhCacheCacheManager cacheManager() {
    return new EhCacheCacheManager(ehCacheManagerFactoryBean().getObject());
}

我还将@EnableCaching放在root配置文件中

对于ehcache.xml,我有以下内容

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="ehcache.xsd"
 updateCheck="true" monitoring="autodetect" dynamicConfig="true">

<diskStore path="java.io.tmpdir" />

<defaultCache maxEntriesLocalHeap="10000" eternal="false"
    timeToIdleSeconds="120" timeToLiveSeconds="120" maxEntriesLocalDisk="10000000"
    diskExpiryThreadIntervalSeconds="120" statistics="true">
</defaultCache>

<cache name="mediumCache"
       maxEntriesLocalHeap="2000"
       eternal="false"
       timeToIdleSeconds="1800"
       timeToLiveSeconds="3600"
       overflowToDisk="false"
       memoryStoreEvictionPolicy="LFU" statistics="true"
    />

<cache name="highCache"
       maxEntriesLocalHeap="2000"
       eternal="false"
       timeToIdleSeconds="3600"
       timeToLiveSeconds="7200"
       overflowToDisk="false"
       memoryStoreEvictionPolicy="LFU" statistics="true"
    />

一切都很好,我的可缓存功能运行良好,现在我想看看 spring Actuator 的统计数据 .

我们怎么做?

1 回答

  • 0

    如果您能够使用 spring 启动的快照版本,则此功能将添加到1.3.0 . 现在你不会在1.2.X中得到它

相关问题