Java Ehcache 2.10.6命中统计信息未增加
我已经在我的一个项目中设置了缓存,以及自定义运行状况指示器,如下所示:Java Ehcache 2.10.6命中统计信息未增加,java,spring,spring-boot,ehcache,spring-boot-actuator,Java,Spring,Spring Boot,Ehcache,Spring Boot Actuator,我已经在我的一个项目中设置了缓存,以及自定义运行状况指示器,如下所示: @Component public class CustomHealthIndicator extends AbstractHealthIndicator { @Override protected void doHealthCheck(Health.Builder builder) { CacheManager cacheManagerInstance = CacheManager
@Component
public 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/exactor/health时,所有其他统计信息都会更新,但点击次数不会更新
{“status”:“UP”,“details”:{“Cache Size”:9,“Cache Hit Count”:0,“Cache”
未命中计数:9,“缓存放置计数”:9,“缓存移除计数”:0,“缓存
过期计数“:0}”
我在另一个项目中访问缓存的代码是:
Cacheable cachedResult = CacheManager.getInstance().getCache(request);
if (cachedResult != null)
{
CustomResponse response = (CustomResponse) cachedResult.getObject();
return response;
}
我可以确认已输入此块,并且缓存中确实存在数据
我不知道为什么点击率统计没有更新。任何帮助都将不胜感激 结果表明,我的对象没有被正确序列化,因此当它在缓存中搜索它们时,找不到它们