Я настроил кэш в одном из моих проектов вместе с пользовательским индикатором работоспособности, как показано ниже:
@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 / привод / здоровье вседругие статистические данные обновляются, но попадания не выполняются.
{"status": "UP", "details": {"Cache Size": 9, "Cache Hit Count": 0, "Cache Miss Count ": 9," Cache Put Count ": 9," Cache Remove Count ": 0," Cache Expired Count ": 0}}
Мой код обращается к кешу в моем другом проектеэто:
Cacheable cachedResult = CacheManager.getInstance().getCache(request);
if (cachedResult != null)
{
CustomResponse response = (CustomResponse) cachedResult.getObject();
return response;
}
Я могу подтвердить, что этот блок введен и что в кеш-памяти действительно есть данные.
Я понятия не имею, почему статистика хитов не обновляется. Любая помощь будет оценена!