我在我的一個項目中設(shè)置了一個緩存,以及自定義運行狀況指示器,如下所示:@Componentpublic class CustomHealthIndicator extends AbstractHealthIndicator{ @Override protected void doHealthCheck(Health.Builder builder) { CacheManager cacheManagerInstance = CacheManager.getInstance(); Ehcache cache = cacheManagerInstance.getCache("myCache"); builder.up() .withDetail("Cache Size", cache.getSize()) .withDetail("Cache Hit Count", cache.getStatistics().cacheHitCount()) .withDetail("Cache Miss Count", cache.getStatistics().cacheMissCount()) .withDetail("Cache Put Count", cache.getStatistics().cachePutCount()) .withDetail("Cache Remove Count", cache.getStatistics().cacheRemoveCount()) .withDetail("Cache Expired Count", cache.getStatistics().cacheExpiredCount()); }當(dāng)我在本地運行它并轉(zhuǎn)到 localhost:8080/actuator/health 時,所有其他統(tǒng)計數(shù)據(jù)都會更新,但點擊次數(shù)不會更新。{“status”:“UP”,“details”:{“緩存大小”:9,“緩存命中計數(shù)”:0,“緩存未命中計數(shù)”:9,“緩存放置計數(shù)”:9,“緩存刪除計數(shù)” :0,"緩存過期計數(shù)":0}}我在其他項目中訪問緩存的代碼是:Cacheable cachedResult = CacheManager.getInstance().getCache(request);if (cachedResult != null){ CustomResponse response = (CustomResponse) cachedResult.getObject(); return response;}我可以確認該塊已被輸入并且緩存中確實有數(shù)據(jù)。我不知道為什么點擊統(tǒng)計沒有更新。任何幫助,將不勝感激!
Ehcache 2.10.6 命中統(tǒng)計數(shù)據(jù)未增加
料青山看我應(yīng)如是
2023-10-13 16:48:47