Enum DisabledStatsCounter
- java.lang.Object
-
- java.lang.Enum<DisabledStatsCounter>
-
- com.github.benmanes.caffeine.cache.stats.DisabledStatsCounter
-
- All Implemented Interfaces:
StatsCounter,java.io.Serializable,java.lang.Comparable<DisabledStatsCounter>
enum DisabledStatsCounter extends java.lang.Enum<DisabledStatsCounter> implements StatsCounter
AStatsCounterimplementation that does not record any cache events.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description privateDisabledStatsCounter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidrecordEviction()Records the eviction of an entry from the cache.voidrecordHits(int count)Records cache hits.voidrecordLoadFailure(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.java.lang.StringtoString()static DisabledStatsCountervalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static DisabledStatsCounter[]values()Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Methods inherited from interface com.github.benmanes.caffeine.cache.stats.StatsCounter
recordEviction, recordEviction
-
-
-
-
Enum Constant Detail
-
INSTANCE
public static final DisabledStatsCounter INSTANCE
-
-
Method Detail
-
values
public static DisabledStatsCounter[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DisabledStatsCounter c : DisabledStatsCounter.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DisabledStatsCounter valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
recordHits
public void recordHits(int count)
Description copied from interface:StatsCounterRecords cache hits. This should be called when a cache request returns a cached value.- Specified by:
recordHitsin interfaceStatsCounter- Parameters:
count- the number of hits to record
-
recordMisses
public void recordMisses(int count)
Description copied from interface: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 eitherrecordLoadSuccessorrecordLoadFailureand multiple calls to this method, despite all being served by the results of a single load operation.- Specified by:
recordMissesin interfaceStatsCounter- Parameters:
count- the number of misses to record
-
recordLoadSuccess
public void recordLoadSuccess(long loadTime)
Description copied from interface:StatsCounterRecords the successful load of a new entry. This method should be called when a cache request causes an entry to be loaded (such as byCache.get(K, java.util.function.Function<? super K, ? extends V>)orMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)) and the loading completes successfully. In contrast toStatsCounter.recordMisses(@org.checkerframework.checker.index.qual.NonNegative int), this method should only be called by the loading thread.- Specified by:
recordLoadSuccessin interfaceStatsCounter- Parameters:
loadTime- the number of nanoseconds the cache spent computing or retrieving the new value
-
recordLoadFailure
public void recordLoadFailure(long loadTime)
Description copied from interface:StatsCounterRecords the failed load of a new entry. This method should be called when a cache request causes an entry to be loaded (such as byCache.get(K, java.util.function.Function<? super K, ? extends V>)orMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)), but an exception is thrown while loading the entry or the loading function returns null. In contrast toStatsCounter.recordMisses(@org.checkerframework.checker.index.qual.NonNegative int), this method should only be called by the loading thread.- Specified by:
recordLoadFailurein interfaceStatsCounter- Parameters:
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
-
recordEviction
public void recordEviction()
Description copied from interface: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 manualinvalidations.- Specified by:
recordEvictionin interfaceStatsCounter
-
snapshot
public CacheStats snapshot()
Description copied from interface:StatsCounterReturns a snapshot of this counter's values. Note that this may be an inconsistent view, as it may be interleaved with update operations.Note: the values of the metrics are undefined in case of overflow (though it is guaranteed not to throw an exception). If you require specific handling, we recommend implementing your own stats collector.
- Specified by:
snapshotin interfaceStatsCounter- Returns:
- a snapshot of this counter's values
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Enum<DisabledStatsCounter>
-
-