Skip to content

withStatsCounter

fun <K, V> Caffeine<K, V>.withStatsCounter(statsCounter: StatsCounter?): Caffeine<K, V>

Applies the StatsCounter to the Caffeine cache builder if it's non-null, or otherwise doesn't register it.

withStatsCounter exists because Caffeine.recordStats itself doesn't handle null stats counters.

Beware: Some operations of Cache.asMap do not record stats, so it's recommended to use the Caffeine cache directly.