public final class ConcurrentStatsCounter extends Object implements StatsCounter
StatsCounter implementation for use by Cache implementors.| Constructor and Description |
|---|
ConcurrentStatsCounter()
Constructs an instance with all counts initialized to zero.
|
| Modifier and Type | Method and Description |
|---|---|
void |
incrementBy(StatsCounter other)
Increments all counters by the values in
other. |
void |
recordEviction()
Records the eviction of an entry from the cache.
|
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.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdisabledStatsCounter, guardedStatsCounterpublic ConcurrentStatsCounter()
public void recordHits(@Nonnegative int count)
StatsCounterrecordHits in interface StatsCountercount - the number of hits to recordpublic void recordMisses(@Nonnegative int count)
StatsCounterCache 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.recordMisses in interface StatsCountercount - the number of misses to recordpublic void recordLoadSuccess(@Nonnegative long loadTime)
StatsCounterStatsCounter.recordMisses(int), this method should only be called by the loading thread.recordLoadSuccess in interface StatsCounterloadTime - the number of nanoseconds the cache spent computing or retrieving the new valuepublic void recordLoadFailure(@Nonnegative long loadTime)
StatsCounterStatsCounter.recordMisses(int), this method should only be called by the loading
thread.recordLoadFailure in interface StatsCounterloadTime - 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 thrownpublic void recordEviction()
StatsCounterinvalidations.recordEviction in interface StatsCounterpublic void recordEviction(int weight)
StatsCounterinvalidations.recordEviction in interface StatsCounterweight - the weight of the evicted entrypublic CacheStats snapshot()
StatsCountersnapshot in interface StatsCounterpublic void incrementBy(@Nonnull StatsCounter other)
other.other - the counter to increment from