@ThreadSafe public interface StatsCounter
Cache for presentation by
Cache.stats(). This is solely intended for consumption by Cache implementors.| Modifier and Type | Method and Description |
|---|---|
static StatsCounter |
disabledStatsCounter()
Returns an accumulator that does not record any cache events.
|
static StatsCounter |
guardedStatsCounter(StatsCounter statsCounter)
Returns an accumulator that suppresses and logs any exception thrown by the delegate
statsCounter.
|
void |
recordEviction()
Deprecated.
Use
recordEviction(int) instead. This method is scheduled for
removal in version 3.0.0. |
default void |
recordEviction(int weight)
Records the eviction of an entry from the cache.
|
void |
recordHits(int count)
Records cache hits.
|
void |
recordLoadFailure(long loadTime)
Records the failed load of a new entry.
|
void |
recordLoadSuccess(long loadTime)
Records the successful load of a new entry.
|
void |
recordMisses(int count)
Records cache misses.
|
CacheStats |
snapshot()
Returns a snapshot of this counter's values.
|
void recordHits(@Nonnegative int count)
count - the number of hits to recordvoid recordMisses(@Nonnegative int count)
Cache lookup methods with the same
key on an absent value should result in a single call to either recordLoadSuccess or
recordLoadFailure and multiple calls to this method, despite all being served by the
results of a single load operation.count - the number of misses to recordvoid recordLoadSuccess(@Nonnegative long loadTime)
recordMisses(int), this method should only be called by the loading thread.loadTime - the number of nanoseconds the cache spent computing or retrieving the new valuevoid recordLoadFailure(@Nonnegative long loadTime)
recordMisses(int), this method should only be called by the loading
thread.loadTime - the number of nanoseconds the cache spent computing or retrieving the new value
prior to discovering the value doesn't exist or an exception being thrown@Deprecated void recordEviction()
recordEviction(int) instead. This method is scheduled for
removal in version 3.0.0.invalidations.default void recordEviction(int weight)
invalidations.weight - the weight of the evicted entry@Nonnull CacheStats snapshot()
@Nonnull static StatsCounter disabledStatsCounter()
@Nonnull static StatsCounter guardedStatsCounter(@Nonnull StatsCounter statsCounter)
statsCounter - the accumulator to delegate to