Interface CacheStats
-
public interface CacheStats
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description double
averageLoadPenalty()
Returns the average time spent loading new values.long
evictionCount()
Returns the number of times an entry has been evicted.long
hitCount()
Returns the number of times lookup methods have returned a cached value.double
hitRate()
Returns the ratio of cache requests which were hits.long
loadCount()
Returns the total number of times that lookup methods attempted to load new values.long
loadExceptionCount()
Returns the number of times lookup methods threw an exception while loading a new value.double
loadExceptionRate()
Returns the ratio of cache loading attempts which threw exceptions.long
loadSuccessCount()
Returns the number of times lookup methods have successfully loaded a new value.CacheStats
minus(CacheStats other)
Returns a newICacheStats
representing the difference between thisICacheStats
andother
.long
missCount()
Returns the number of times lookup methods have returned an uncached (newly loaded) value, or null.double
missRate()
Returns the ratio of cache requests which were misses.CacheStats
plus(CacheStats other)
Returns a newICacheStats
representing the sum of thisICacheStats
andother
.long
requestCount()
Returns the number of times lookup methods have returned either a cached or uncached value.long
totalLoadTime()
Returns the total number of nanoseconds the cache has spent loading new values.
-
-
-
Method Detail
-
requestCount
long requestCount()
Returns the number of times lookup methods have returned either a cached or uncached value. This is defined ashitCount + missCount
.Note: the values of the metrics are undefined in case of overflow (though it is guaranteed not to throw an exception). If you require specific handling, we recommend implementing your own stats collector.
-
hitCount
long hitCount()
Returns the number of times lookup methods have returned a cached value.
-
hitRate
double hitRate()
Returns the ratio of cache requests which were hits. This is defined ashitCount / requestCount
, or1.0
whenrequestCount == 0
. Note thathitRate + missRate =~ 1.0
.
-
missCount
long missCount()
Returns the number of times lookup methods have returned an uncached (newly loaded) value, or null. Multiple concurrent calls to lookup methods on an absent value can result in multiple misses, all returning the results of a single cache load operation.
-
missRate
double missRate()
Returns the ratio of cache requests which were misses. This is defined asmissCount / requestCount
, or0.0
whenrequestCount == 0
. Note thathitRate + missRate =~ 1.0
. Cache misses include all requests which weren't cache hits, including requests which resulted in either successful or failed loading attempts, and requests which waited for other threads to finish loading. It is thus the case thatmissCount >= loadSuccessCount + loadExceptionCount
. Multiple concurrent misses for the same key will result in a single load operation.
-
loadCount
long loadCount()
Returns the total number of times that lookup methods attempted to load new values. This includes both successful load operations and those that threw exceptions. This is defined asloadSuccessCount + loadExceptionCount
.Note: the values of the metrics are undefined in case of overflow (though it is guaranteed not to throw an exception). If you require specific handling, we recommend implementing your own stats collector.
-
loadSuccessCount
long loadSuccessCount()
Returns the number of times lookup methods have successfully loaded a new value. This is usually incremented in conjunction withmissCount()
, thoughmissCount
is also incremented when an exception is encountered during cache loading (seeloadExceptionCount()
). Multiple concurrent misses for the same key will result in a single load operation. This may be incremented not in conjunction withmissCount
if the load occurs as a result of a refresh or if the cache loader returned more items than was requested.missCount
may also be incremented not in conjunction with this (norloadExceptionCount()
) on calls togetIfPresent
.
-
loadExceptionCount
long loadExceptionCount()
Returns the number of times lookup methods threw an exception while loading a new value. This is usually incremented in conjunction withmissCount
, thoughmissCount
is also incremented when cache loading completes successfully (seeloadSuccessCount()
). Multiple concurrent misses for the same key will result in a single load operation. This may be incremented not in conjunction withmissCount
if the load occurs as a result of a refresh or if the cache loader returned more items than was requested.missCount
may also be incremented not in conjunction with this (norloadSuccessCount()
) on calls togetIfPresent
.
-
loadExceptionRate
double loadExceptionRate()
Returns the ratio of cache loading attempts which threw exceptions. This is defined asloadExceptionCount / (loadSuccessCount + loadExceptionCount)
, or0.0
whenloadSuccessCount + loadExceptionCount == 0
.Note: the values of the metrics are undefined in case of overflow (though it is guaranteed not to throw an exception). If you require specific handling, we recommend implementing your own stats collector.
-
totalLoadTime
long totalLoadTime()
Returns the total number of nanoseconds the cache has spent loading new values. This can be used to calculate the miss penalty. This value is increased every timeloadSuccessCount
orloadExceptionCount
is incremented.
-
averageLoadPenalty
double averageLoadPenalty()
Returns the average time spent loading new values. This is defined astotalLoadTime / (loadSuccessCount + loadExceptionCount)
.Note: the values of the metrics are undefined in case of overflow (though it is guaranteed not to throw an exception). If you require specific handling, we recommend implementing your own stats collector.
-
evictionCount
long evictionCount()
Returns the number of times an entry has been evicted. This count does not include manual invalidations.
-
minus
CacheStats minus(CacheStats other)
Returns a newICacheStats
representing the difference between thisICacheStats
andother
. Negative values, which aren't supported byICacheStats
will be rounded up to zero.
-
plus
CacheStats plus(CacheStats other)
Returns a newICacheStats
representing the sum of thisICacheStats
andother
.Note: the values of the metrics are undefined in case of overflow (though it is guaranteed not to throw an exception). If you require specific handling, we recommend implementing your own stats collector.
-
-