com.google.common.cache
Class AbstractCache.SimpleStatsCounter

java.lang.Object
  extended by com.google.common.cache.AbstractCache.SimpleStatsCounter
All Implemented Interfaces:
AbstractCache.StatsCounter
Enclosing class:
AbstractCache<K,V>

@Beta
public static class AbstractCache.SimpleStatsCounter
extends Object
implements AbstractCache.StatsCounter

A thread-safe AbstractCache.StatsCounter implementation for use by Cache implementors.

Since:
10.0

Constructor Summary
AbstractCache.SimpleStatsCounter()
           
 
Method Summary
 void incrementBy(AbstractCache.StatsCounter other)
          Increments all counters by the values in other.
 void recordConcurrentMiss()
          Records a single concurrent miss.
 void recordEviction()
          Records the eviction of an entry from the cache.
 void recordHit()
          Records a single hit.
 void recordLoadException(long loadTime)
          Records the failed load of a new entry.
 void recordLoadSuccess(long loadTime)
          Records the successful load of a new entry.
 CacheStats snapshot()
          Returns a snapshot of this counter's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCache.SimpleStatsCounter

public AbstractCache.SimpleStatsCounter()
Method Detail

recordHit

public void recordHit()
Description copied from interface: AbstractCache.StatsCounter
Records a single hit. This should be called when a cache request returns a cached value.

Specified by:
recordHit in interface AbstractCache.StatsCounter

recordLoadSuccess

public void recordLoadSuccess(long loadTime)
Description copied from interface: AbstractCache.StatsCounter
Records 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 succesfully. In contrast to AbstractCache.StatsCounter.recordConcurrentMiss(), this method should only be called by the loading thread.

Specified by:
recordLoadSuccess in interface AbstractCache.StatsCounter
Parameters:
loadTime - the number of nanoseconds the cache spent computing or retrieving the new value

recordLoadException

public void recordLoadException(long loadTime)
Description copied from interface: AbstractCache.StatsCounter
Records 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 to AbstractCache.StatsCounter.recordConcurrentMiss(), this method should only be called by the loading thread.

Specified by:
recordLoadException in interface AbstractCache.StatsCounter
Parameters:
loadTime - the number of nanoseconds the cache spent computing or retrieving the new value prior to an exception being thrown

recordConcurrentMiss

public void recordConcurrentMiss()
Description copied from interface: AbstractCache.StatsCounter
Records a single concurrent miss. This should be called when a cache request returns a value which was loaded by a different thread. In contrast to AbstractCache.StatsCounter.recordLoadSuccess(long) and AbstractCache.StatsCounter.recordLoadException(long), this method should never be called by the loading thread. Multiple concurrent calls to Cache lookup methods with the same key on an absent value should result in a single call to either recordLoadSuccess or recordLoadException and multiple calls to this method, despite all being served by the results of a single load operation.

Specified by:
recordConcurrentMiss in interface AbstractCache.StatsCounter

recordEviction

public void recordEviction()
Description copied from interface: AbstractCache.StatsCounter
Records 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:
recordEviction in interface AbstractCache.StatsCounter

snapshot

public CacheStats snapshot()
Description copied from interface: AbstractCache.StatsCounter
Returns 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:
snapshot in interface AbstractCache.StatsCounter

incrementBy

public void incrementBy(AbstractCache.StatsCounter other)
Increments all counters by the values in other.



Copyright © 2010-2011. All Rights Reserved.