Fix EhCache hit/miss ratio

The hitRatio is the ratio of two windowed rates that are calculated
independently. They are not updated or read transactionally, hence the
ratio of the two can drift slightly from what might be expected.

We now make sure that the hit or miss ratio can't be higher than 1

Closes gh-3235
pull/3254/head
izeye 10 years ago committed by Stephane Nicoll
parent bbb27cf272
commit 2b9775d593

@ -37,8 +37,8 @@ public class EhCacheStatisticsProvider implements CacheStatisticsProvider<EhCach
statistics.setSize(ehCacheStatistics.getSize());
Double hitRatio = ehCacheStatistics.cacheHitRatio();
if (!hitRatio.isNaN()) {
statistics.setHitRatio(hitRatio);
statistics.setMissRatio(1 - hitRatio);
statistics.setHitRatio(hitRatio > 1 ? 1 : hitRatio);
statistics.setMissRatio(hitRatio > 1 ? 0 : 1 - hitRatio);
}
return statistics;
}

Loading…
Cancel
Save