为了账号安全,请及时绑定邮箱和手机立即绑定

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条经验 获得超2个赞

事实证明,我的对象没有被正确序列化,因此当它在缓存中搜索它们时,没有找到它们。



查看完整回答
反对 回复 2023-10-13
  • 1 回答
  • 0 关注
  • 55 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信