net.sf.ehcache.Cache.setStatisticsEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中net.sf.ehcache.Cache.setStatisticsEnabled()方法的一些代码示例,展示了Cache.setStatisticsEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.setStatisticsEnabled()方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:setStatisticsEnabled

Cache.setStatisticsEnabled介绍

暂无

代码示例

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * {@inheritDoc}
 */
public void disableStatistics() {
  for (String cacheName : getCacheNames()) {
    Cache cache = cacheManager.getCache(cacheName);
    if (cache != null) {
      // disables regular statistics also
      cache.setStatisticsEnabled(false);
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * {@inheritDoc}
 */
public void setStatisticsEnabled(boolean flag) {
  for (String cacheName : cacheManager.getCacheNames()) {
    Cache cache = cacheManager.getCache(cacheName);
    if (cache != null) {
      cache.setStatisticsEnabled(flag);
    }
  }
  if (flag) {
    clearStats();
  }
  sendNotification(CACHE_STATISTICS_ENABLED, flag);
}

代码示例来源:origin: stackoverflow.com

public class RefCacheTest extends AbstractTest {
 @Autowired
 private RefSituationService refSituationService;
 @Autowired
 private RefCivilityService refCivilityService;
 @Autowired
 private CacheManager cacheManager;
 @Test
 public void findById() {
   Cache refCache = cacheManager.getCache(MyCache.REFS);
   refCache.setStatisticsEnabled(true);
   assertThat(refSituationService.findById(1L)).isInstanceOf(RefSituation.class);
   assertThat(refSituationService.findById(1L)).isInstanceOf(RefSituation.class);
   assertThat(refSituationService.findById(2L)).isInstanceOf(RefSituation.class);
   assertThat(refCivilityService.findById(1L)).isInstanceOf(RefCivility.class);
   assertThat(refCivilityService.findById(1L)).isInstanceOf(RefCivility.class);
   assertThat(refCivilityService.findById(2L)).isInstanceOf(RefCivility.class);
   System.out.println(refCache.getName() +" - "+ refCache.getStatistics().toString()); 
   assertThat(refCache.getStatistics().getCacheHits()).isEqualTo(2);
   assertThat(refCache.getSize()).isEqualTo(4);
 }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * {@inheritDoc}
 */
public void setSampledStatisticsEnabled(final boolean enableStatistics) {
  if (cacheManager == null) {
    throw new IllegalStateException("You must add the cache to a CacheManager before enabling/disabling sampled statistics.");
  }
  boolean oldValue = isSampledStatisticsEnabled();
  if (oldValue != enableStatistics) {
    if (enableStatistics) {
      ManagementRESTServiceConfiguration mgmtRESTConfigSvc = cacheManager.getConfiguration().getManagementRESTService();
      if (mgmtRESTConfigSvc != null && mgmtRESTConfigSvc.isEnabled()) {
        sampledCacheStatistics.enableSampledStatistics(cacheManager.getTimer(), mgmtRESTConfigSvc.makeSampledCounterConfig(),
            mgmtRESTConfigSvc.makeSampledGetRateCounterConfig(), mgmtRESTConfigSvc.makeSampledSearchRateCounterConfig());
      } else {
        sampledCacheStatistics.enableSampledStatistics(cacheManager.getTimer());
      }
      setStatisticsEnabled(true);
    } else {
      sampledCacheStatistics.disableSampledStatistics();
    }
    firePropertyChange("SampledStatisticsEnabled", oldValue, enableStatistics);
  }
}

相关文章

微信公众号

最新文章

更多

Cache类方法