Cache.
Cache statistics are incremented according to the following rules:
hitCount is incremented.
missCount and loadSuccessCount are
incremented, and the total loading time, in nanoseconds, is added to
totalLoadTime.
missCount and loadFailureCount are incremented, and the total loading
time, in nanoseconds, is added to totalLoadTime.
missCount.
loadSuccessCount or loadFailureCount is incremented.
evictionCount is incremented and the
weight added to evictionWeight.
A lookup is specifically defined as an invocation of one of the methods
LoadingCache#get(Object), Cache#get(Object, java.util.function.Function), or
LoadingCache#getAll(Iterable).
This is a value-based class; use of identity-sensitive operations (including reference
equality (==), identity hash code, or synchronization) on instances of CacheStats
may have unpredictable results and should be avoided.
| Modifier and Type | Field and Description |
|---|---|
| private static final CacheStats | |
| private final long | |
| private final long | |
| private final long | |
| private final long | |
| private final long | |
| private final long | |
| private final long |
| Access | Constructor and Description |
|---|---|
| private | CacheStats(@NonNegative long hitCount, @NonNegative long missCount, @NonNegative long loadSuccessCount, @NonNegative long loadFailureCount, @NonNegative long totalLoadTime, @NonNegative long evictionCount, @NonNegative long evictionWeight)
|
| Modifier and Type | Method and Description |
|---|---|
| public @NonNegative double | Returns: the average number of nanoseconds spent loading new valuesReturns the average number of nanoseconds spent loading new values. |
| public static CacheStats | Returns: an empty statistics instanceReturns a statistics instance where no cache events have been recorded. |
| public boolean | equals(@Nullable Object
the reference object with which to compare. o)Overrides java. |
| public @NonNegative long | Returns: the number of times an entry has been evictedReturns the number of times an entry has been evicted. |
| public @NonNegative long | Returns: the sum of weights of evicted entitiesReturns the sum of weights of evicted entries. |
| public int | |
| public @NonNegative long | |
| public @NonNegative double | Returns: the ratio of cache requests which were hitsReturns the ratio of cache requests which were hits. |
| public @NonNegative long | |
| public @NonNegative long | Returns: the number of timesCache lookup methods failed to load a new valueReturns the number of times |
| public @NonNegative double | Returns: the ratio of cache loading attempts which threw exceptionsReturns the ratio of cache loading attempts which threw exceptions. |
| public @NonNegative long | Returns: the number of timesCache lookup methods have successfully loaded a new valueReturns the number of times |
| public CacheStats | Returns: the difference between this instance andotherthe statistics to subtract with other)Returns a new |
| public @NonNegative long | |
| public @NonNegative double | Returns: the ratio of cache requests which were missesReturns the ratio of cache requests which were misses. |
| public static CacheStats | Returns: aCacheStats representing the specified statisticsthe number of cache hits hitCount, @NonNegative long the number of cache misses missCount, @NonNegative long the number of successful cache loads loadSuccessCount, @NonNegative long the number of failed cache loads loadFailureCount, @NonNegative long the total load time (success and failure) totalLoadTime, @NonNegative long the number of entries evicted from the cache evictionCount, @NonNegative long the sum of weights of entries evicted from the cache evictionWeight)Returns a |
| public CacheStats | Returns: the sum of the statisticsthe statistics to add with other)Returns a new |
| public @NonNegative long | Returns: thehitCount + missCountReturns the number of times |
| private static long | saturatedAdd(long a, long b)
Returns the sum of |
| public String | |
| public @NonNegative long | Returns: the total number of nanoseconds the cache has spent loading new valuesReturns the total number of nanoseconds the cache has spent loading new values. |
| EMPTY_STATS | back to summary |
|---|---|
| private static final CacheStats EMPTY_STATS | |
| evictionCount | back to summary |
|---|---|
| private final long evictionCount | |
| evictionWeight | back to summary |
|---|---|
| private final long evictionWeight | |
| hitCount | back to summary |
|---|---|
| private final long hitCount | |
| loadFailureCount | back to summary |
|---|---|
| private final long loadFailureCount | |
| loadSuccessCount | back to summary |
|---|---|
| private final long loadSuccessCount | |
| missCount | back to summary |
|---|---|
| private final long missCount | |
| totalLoadTime | back to summary |
|---|---|
| private final long totalLoadTime | |
| CacheStats | back to summary |
|---|---|
| private CacheStats(@NonNegative long hitCount, @NonNegative long missCount, @NonNegative long loadSuccessCount, @NonNegative long loadFailureCount, @NonNegative long totalLoadTime, @NonNegative long evictionCount, @NonNegative long evictionWeight) | |
| averageLoadPenalty | back to summary |
|---|---|
| public @NonNegative double averageLoadPenalty() Returns the average number of nanoseconds spent loading new values. This is defined as
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.
| |
| empty | back to summary |
|---|---|
| public static CacheStats empty() Returns a statistics instance where no cache events have been recorded.
| |
| equals | back to summary |
|---|---|
| public boolean equals(@Nullable Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| evictionCount | back to summary |
|---|---|
| public @NonNegative long evictionCount() Returns the number of times an entry has been evicted. This count does not include manual invalidations.
| |
| evictionWeight | back to summary |
|---|---|
| public @NonNegative long evictionWeight() Returns the sum of weights of evicted entries. This total does not include manual invalidations.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| hitCount | back to summary |
|---|---|
| public @NonNegative long hitCount() Returns the number of times
| |
| hitRate | back to summary |
|---|---|
| public @NonNegative double hitRate() Returns the ratio of cache requests which were hits. This is defined as
| |
| loadCount | back to summary |
|---|---|
| public @NonNegative long loadCount() Returns the total number of times that 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.
| |
| loadFailureCount | back to summary |
|---|---|
| public @NonNegative long loadFailureCount() Returns the number of times
| |
| loadFailureRate | back to summary |
|---|---|
| public @NonNegative double loadFailureRate() Returns the ratio of cache loading attempts which threw exceptions. This is defined as
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 | back to summary |
|---|---|
| public @NonNegative long loadSuccessCount() Returns the number of times
| |
| minus | back to summary |
|---|---|
| public CacheStats minus(CacheStats other) Returns a new
| |
| missCount | back to summary |
|---|---|
| public @NonNegative long missCount() Returns the number of times
| |
| missRate | back to summary |
|---|---|
| public @NonNegative double missRate() Returns the ratio of cache requests which were misses. This is defined as
| |
| of | back to summary |
|---|---|
| public static CacheStats of(@NonNegative long hitCount, @NonNegative long missCount, @NonNegative long loadSuccessCount, @NonNegative long loadFailureCount, @NonNegative long totalLoadTime, @NonNegative long evictionCount, @NonNegative long evictionWeight) Returns a
| |
| plus | back to summary |
|---|---|
| public CacheStats plus(CacheStats other) Returns a new 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.
| |
| requestCount | back to summary |
|---|---|
| public @NonNegative long requestCount() Returns the number of times 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.
| |
| saturatedAdd | back to summary |
|---|---|
| private static long saturatedAdd(long a, long b) Returns the sum of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| totalLoadTime | back to summary |
|---|---|
| public @NonNegative 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 time
| |