2014-10-22 3 views
2

서버를 실행할 때 Ehcache에 대한 모든 통계를보고 싶습니다. 설명서에서 "StatisticsGateway"및 "SampledCache"와 같은 개체를 발견했습니다. 나는 ehcache 2.9를 사용하고있다.Ehcache 통계

StatisticsGateway를 사용하면 통계가 불완전 해집니다. SampledCache 객체를 사용할 때 더 많은 통계를 얻지 만, 어떤 방법 으로든 객체를 검색하는 데는 아무 것도 설명되어 있지 않습니다.

Cache cache = cacheManager.getCache("name"); 
StatisticsGateway statistic = cache.getStatistics(); 
statistic.cacheHitCount() etc. 

가 어떻게 SampledCache 개체를 얻을 : 예를 들어

는 StatisticsGateway 객체를 얻는 것은 다음과 같다? 사전에

감사합니다!

답변

1

SampleCache는 데코레이터 객체의 역할을합니다. 기본적으로 SampledCache의 인스턴스를 만들고 캐시 인스턴스를 백업 캐시로 전달합니다. 백업 캐시는 통계가 필요한 캐시이며, 경우에 따라 캐시 인스턴스입니다.

SampledCache sampledCache = new SampledCache(cache);

같은 뭔가 당신이 원하는 통계를 얻을 수 sampledCache에 메서드를 호출 할 수 있습니다. 여기에 간단한 예제를 만들었습니다 http://www.ashishpaliwal.com/blog/2015/01/using-ehcache-sampledcache/

2

늦게 답변 :) 다른 사람에게 도움이 될 수 있습니다.

java/bin 디렉토리에서 jconsole.exe를 사용할 수 있습니다. Jconsole은 통계를 보여줍니다.

당신은

<!-- JMX for Ehcache --> 
    <bean id="managementService" class="net.sf.ehcache.management.ManagementService" 
     init-method="init" destroy-method="dispose"> 
     <constructor-arg ref="ehcache" /> 
     <constructor-arg ref="mbeanServer" /> 
     <constructor-arg index="2" value="true" /> 
     <constructor-arg index="3" value="true" /> 
     <constructor-arg index="4" value="true" /> 
     <constructor-arg index="5" value="true" /> 
    </bean> 
JConsole의

의 통계를 볼 수 있습니다 JMX 지원을 추가해야 할 수도 있습니다