亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Ehcache 2.10.6 命中統計數據未增加

Ehcache 2.10.6 命中統計數據未增加

料青山看我應如是 2023-10-13 16:48:47
我在我的一個項目中設置了一個緩存,以及自定義運行狀況指示器,如下所示:@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());    }當我在本地運行它并轉到 localhost:8080/actuator/health 時,所有其他統計數據都會更新,但點擊次數不會更新。{“status”:“UP”,“details”:{“緩存大小”:9,“緩存命中計數”:0,“緩存未命中計數”:9,“緩存放置計數”:9,“緩存刪除計數” :0,"緩存過期計數":0}}我在其他項目中訪問緩存的代碼是:Cacheable cachedResult = CacheManager.getInstance().getCache(request);if (cachedResult != null){    CustomResponse response = (CustomResponse) cachedResult.getObject();    return response;}我可以確認該塊已被輸入并且緩存中確實有數據。我不知道為什么點擊統計沒有更新。任何幫助,將不勝感激!
查看完整描述

1 回答

?
一只名叫tom的貓

TA貢獻1906條經驗 獲得超3個贊

事實證明,我的對象沒有被正確序列化,因此當它在緩存中搜索它們時,沒有找到它們。



查看完整回答
反對 回復 2023-10-13
  • 1 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號