Top Description Fields Constructors Methods
com.github.benmanes.caffeine.cache.stats

public final Class ConcurrentStatsCounter

extends Object
implements StatsCounter
Class Inheritance
All Implemented Interfaces
com.github.benmanes.caffeine.cache.stats.StatsCounter
Static Imports
java.util.Objects.requireNonNull

A thread-safe StatsCounter implementation for use by Cache implementors.
Author
[email protected] (Ben Manes)

Field Summary

Modifier and TypeField and Description
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder

Constructor Summary

AccessConstructor and Description
public
ConcurrentStatsCounter()

Constructs an instance with all counts initialized to zero.

Method Summary

Modifier and TypeMethod and Description
public void
incrementBy(StatsCounter
the counter to increment from
other
)

Increments all counters by the values in other.

private static long
negativeToMaxValue(long value)

Returns value, if non-negative.

public void
recordEviction(int weight, RemovalCause cause)

public void
recordHits(int count)

public void
recordLoadFailure(long loadTime)

public void
recordLoadSuccess(long loadTime)

public void
recordMisses(int count)

public CacheStats
snapshot()

Implements com.github.benmanes.caffeine.cache.stats.StatsCounter.snapshot.

Returns a snapshot of this counter's values.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

evictionCountback to summary
private final LongAdder evictionCount
evictionWeightback to summary
private final LongAdder evictionWeight
hitCountback to summary
private final LongAdder hitCount
loadFailureCountback to summary
private final LongAdder loadFailureCount
loadSuccessCountback to summary
private final LongAdder loadSuccessCount
missCountback to summary
private final LongAdder missCount
totalLoadTimeback to summary
private final LongAdder totalLoadTime

Constructor Detail

ConcurrentStatsCounterback to summary
public ConcurrentStatsCounter()

Constructs an instance with all counts initialized to zero.

Method Detail

incrementByback to summary
public void incrementBy(StatsCounter other)

Increments all counters by the values in other.

Parameters
other:StatsCounter

the counter to increment from

negativeToMaxValueback to summary
private static long negativeToMaxValue(long value)

Returns value, if non-negative. Otherwise, returns Long#MAX_VALUE.

recordEvictionback to summary
public void recordEviction(int weight, RemovalCause cause)
Annotations
@Override
recordHitsback to summary
public void recordHits(int count)
Annotations
@Override
recordLoadFailureback to summary
public void recordLoadFailure(long loadTime)
Annotations
@Override
recordLoadSuccessback to summary
public void recordLoadSuccess(long loadTime)
Annotations
@Override
recordMissesback to summary
public void recordMisses(int count)
Annotations
@Override
snapshotback to summary
public CacheStats snapshot()

Implements com.github.benmanes.caffeine.cache.stats.StatsCounter.snapshot.

Doc from com.github.benmanes.caffeine.cache.stats.StatsCounter.snapshot.

Returns 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.

Returns:CacheStats

a snapshot of this counter's values

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override