public final class ConcurrentStatsCounter extends java.lang.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.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
disabledStatsCounter, guardedStatsCounter
public ConcurrentStatsCounter()
public void recordHits(@Nonnegative int count)
StatsCounter
recordHits
in interface StatsCounter
count
- the number of hits to recordpublic void recordMisses(@Nonnegative int count)
StatsCounter
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.recordMisses
in interface StatsCounter
count
- the number of misses to recordpublic void recordLoadSuccess(@Nonnegative long loadTime)
StatsCounter
StatsCounter.recordMisses(int)
, this method should only be called by the loading thread.recordLoadSuccess
in interface StatsCounter
loadTime
- the number of nanoseconds the cache spent computing or retrieving the new valuepublic void recordLoadFailure(@Nonnegative long loadTime)
StatsCounter
StatsCounter.recordMisses(int)
, this method should only be called by the loading
thread.recordLoadFailure
in interface StatsCounter
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 thrownpublic void recordEviction()
StatsCounter
invalidations
.recordEviction
in interface StatsCounter
public void recordEviction(int weight)
StatsCounter
invalidations
.recordEviction
in interface StatsCounter
weight
- the weight of the evicted entrypublic CacheStats snapshot()
StatsCounter
snapshot
in interface StatsCounter
public void incrementBy(@Nonnull StatsCounter other)
other
.other
- the counter to increment frompublic java.lang.String toString()
toString
in class java.lang.Object