Class JCacheStatisticsMXBean
java.lang.Object
com.github.benmanes.caffeine.jcache.management.JCacheStatisticsMXBean
- All Implemented Interfaces:
javax.cache.management.CacheStatisticsMXBean
public final class JCacheStatisticsMXBean
extends Object
implements javax.cache.management.CacheStatisticsMXBean
Caffeine JCache statistics.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static floataverage(long requestCount, long opsTimeNanos) voidclear()voidenable(boolean enabled) Sets whether the statistic collection is enabled.floatfloatfloatlonglongfloatlonglongfloatlonglongbooleanvoidrecordEvictions(@NonNegative long count) Records cache evictions.voidrecordGetTime(long durationNanos) Records the time to execute get operations.voidrecordHits(@NonNegative long count) Records cache hits.voidrecordMisses(@NonNegative long count) Records cache misses.voidrecordPuts(@NonNegative long count) Records cache insertion and updates.voidrecordPutTime(long durationNanos) Records the time to execute put operations.voidrecordRemovals(@NonNegative long count) Records cache removals.voidrecordRemoveTime(long durationNanos) Records the time to execute remove operations.
-
Field Details
-
puts
-
hits
-
misses
-
removals
-
evictions
-
putTimeNanos
-
getTimeNanos
-
removeTimeNanos
-
enabled
private volatile boolean enabled
-
-
Constructor Details
-
JCacheStatisticsMXBean
public JCacheStatisticsMXBean()
-
-
Method Details
-
isEnabled
public boolean isEnabled()- Returns:
- if statistic collection is enabled.
-
enable
public void enable(boolean enabled) Sets whether the statistic collection is enabled.- Parameters:
enabled- whether to collect statistics
-
clear
public void clear()- Specified by:
clearin interfacejavax.cache.management.CacheStatisticsMXBean
-
getCacheHits
public long getCacheHits()- Specified by:
getCacheHitsin interfacejavax.cache.management.CacheStatisticsMXBean
-
getCacheHitPercentage
public float getCacheHitPercentage()- Specified by:
getCacheHitPercentagein interfacejavax.cache.management.CacheStatisticsMXBean
-
recordHits
public void recordHits(@NonNegative long count) Records cache hits. This should be called when a cache request returns a cached value.- Parameters:
count- the number of hits to record
-
getCacheMisses
public long getCacheMisses()- Specified by:
getCacheMissesin interfacejavax.cache.management.CacheStatisticsMXBean
-
getCacheMissPercentage
public float getCacheMissPercentage()- Specified by:
getCacheMissPercentagein interfacejavax.cache.management.CacheStatisticsMXBean
-
recordMisses
public void recordMisses(@NonNegative long count) Records cache misses. This should be called when a cache request returns a value that was not found in the cache.- Parameters:
count- the number of misses to record
-
getCacheGets
public long getCacheGets()- Specified by:
getCacheGetsin interfacejavax.cache.management.CacheStatisticsMXBean
-
getCachePuts
public long getCachePuts()- Specified by:
getCachePutsin interfacejavax.cache.management.CacheStatisticsMXBean
-
recordPuts
public void recordPuts(@NonNegative long count) Records cache insertion and updates.- Parameters:
count- the number of writes to record
-
getCacheRemovals
public long getCacheRemovals()- Specified by:
getCacheRemovalsin interfacejavax.cache.management.CacheStatisticsMXBean
-
recordRemovals
public void recordRemovals(@NonNegative long count) Records cache removals.- Parameters:
count- the number of removals to record
-
getCacheEvictions
public long getCacheEvictions()- Specified by:
getCacheEvictionsin interfacejavax.cache.management.CacheStatisticsMXBean
-
recordEvictions
public void recordEvictions(@NonNegative long count) Records cache evictions.- Parameters:
count- the number of evictions to record
-
getAverageGetTime
public float getAverageGetTime()- Specified by:
getAverageGetTimein interfacejavax.cache.management.CacheStatisticsMXBean
-
recordGetTime
public void recordGetTime(long durationNanos) Records the time to execute get operations. This time does not include the time it takes to load an entry on a cache miss, as specified by the specification.- Parameters:
durationNanos- the amount of time in nanoseconds
-
getAveragePutTime
public float getAveragePutTime()- Specified by:
getAveragePutTimein interfacejavax.cache.management.CacheStatisticsMXBean
-
recordPutTime
public void recordPutTime(long durationNanos) Records the time to execute put operations.- Parameters:
durationNanos- the amount of time in nanoseconds
-
getAverageRemoveTime
public float getAverageRemoveTime()- Specified by:
getAverageRemoveTimein interfacejavax.cache.management.CacheStatisticsMXBean
-
recordRemoveTime
public void recordRemoveTime(long durationNanos) Records the time to execute remove operations.- Parameters:
durationNanos- the amount of time in nanoseconds
-
average
private static float average(long requestCount, long opsTimeNanos)
-