Package com.google.common.cache
Class AbstractCache.SimpleStatsCounter
- java.lang.Object
- 
- com.google.common.cache.AbstractCache.SimpleStatsCounter
 
- 
- All Implemented Interfaces:
- AbstractCache.StatsCounter
 - Enclosing class:
- AbstractCache<K,V>
 
 public static final class AbstractCache.SimpleStatsCounter extends java.lang.Object implements AbstractCache.StatsCounter A thread-safeAbstractCache.StatsCounterimplementation for use byCacheimplementors.- Since:
- 10.0
 
- 
- 
Constructor SummaryConstructors Constructor Description SimpleStatsCounter()Constructs an instance with all counts initialized to zero.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidincrementBy(AbstractCache.StatsCounter other)Increments all counters by the values inother.voidrecordEviction()Records the eviction of an entry from the cache.voidrecordHits(int count)Records cache hits.voidrecordLoadException(long loadTime)Records the failed load of a new entry.voidrecordLoadSuccess(long loadTime)Records the successful load of a new entry.voidrecordMisses(int count)Records cache misses.CacheStatssnapshot()Returns a snapshot of this counter's values.
 
- 
- 
- 
Constructor Detail- 
SimpleStatsCounterpublic SimpleStatsCounter() Constructs an instance with all counts initialized to zero.
 
- 
 - 
Method Detail- 
recordHitspublic void recordHits(int count) Description copied from interface:AbstractCache.StatsCounterRecords cache hits. This should be called when a cache request returns a cached value.- Specified by:
- recordHitsin interface- AbstractCache.StatsCounter
- Parameters:
- count- the number of hits to record
- Since:
- 11.0
 
 - 
recordMissespublic void recordMisses(int count) Description copied from interface:AbstractCache.StatsCounterRecords cache misses. This should be called when a cache request returns a value that was not found in the cache. This method should be called by the loading thread, as well as by threads blocking on the load. Multiple concurrent calls toCachelookup methods with the same key on an absent value should result in a single call to eitherrecordLoadSuccessorrecordLoadExceptionand multiple calls to this method, despite all being served by the results of a single load operation.- Specified by:
- recordMissesin interface- AbstractCache.StatsCounter
- Parameters:
- count- the number of misses to record
- Since:
- 11.0
 
 - 
recordLoadSuccesspublic void recordLoadSuccess(long loadTime) Description copied from interface:AbstractCache.StatsCounterRecords the successful load of a new entry. This should be called when a cache request causes an entry to be loaded, and the loading completes successfully. In contrast toAbstractCache.StatsCounter.recordMisses(int), this method should only be called by the loading thread.- Specified by:
- recordLoadSuccessin interface- AbstractCache.StatsCounter
- Parameters:
- loadTime- the number of nanoseconds the cache spent computing or retrieving the new value
 
 - 
recordLoadExceptionpublic void recordLoadException(long loadTime) Description copied from interface:AbstractCache.StatsCounterRecords the failed load of a new entry. This should be called when a cache request causes an entry to be loaded, but an exception is thrown while loading the entry. In contrast toAbstractCache.StatsCounter.recordMisses(int), this method should only be called by the loading thread.- Specified by:
- recordLoadExceptionin interface- AbstractCache.StatsCounter
- Parameters:
- loadTime- the number of nanoseconds the cache spent computing or retrieving the new value prior to an exception being thrown
 
 - 
recordEvictionpublic void recordEviction() Description copied from interface:AbstractCache.StatsCounterRecords the eviction of an entry from the cache. This should only been called when an entry is evicted due to the cache's eviction strategy, and not as a result of manual invalidations.- Specified by:
- recordEvictionin interface- AbstractCache.StatsCounter
 
 - 
snapshotpublic CacheStats snapshot() Description copied from interface:AbstractCache.StatsCounterReturns a snapshot of this counter's values. Note that this may be an inconsistent view, as it may be interleaved with update operations.- Specified by:
- snapshotin interface- AbstractCache.StatsCounter
 
 - 
incrementBypublic void incrementBy(AbstractCache.StatsCounter other) Increments all counters by the values inother.
 
- 
 
-