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
This commit is contained in:
izeye 2015-06-15 21:27:32 +09:00 committed by Stephane Nicoll
parent bbb27cf272
commit 2b9775d593
1 changed files with 2 additions and 2 deletions

View File

@ -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;
}