public interface HitRatio
| Modifier and Type | Method and Description |
|---|---|
double |
getHitRatio()
Returns the ratio between hits and misses
|
default void |
incrementHitCount()
Registers the fact of single hit.
|
default void |
incrementMissCount()
Registers the fact of single miss.
|
void |
update(int hitCount,
int totalCount)
Registers an result of bulk operations.
|
default void incrementHitCount()
Example of usage:
Something cached = cache.get(id);
if (cached != null) {
hitRatio.incrementHitCount();
} else {
hitRatio.incrementMissCount();
}
default void incrementMissCount()
Example of usage:
Something cached = cache.get(id);
if (cached != null) {
hitRatio.incrementHitCount();
} else {
hitRatio.incrementMissCount();
}
void update(int hitCount,
int totalCount)
Example of usage:
Set<Something> cachedValues = cache.get(keys);
hitRatio.update(cachedValues.size(), keys.size());
hitCount - totalCount - IllegalArgumentException - In case of:hitCount < 0totalCount < 1hitCount > totalCountdouble getHitRatio()
Copyright © 2020. All rights reserved.