Skip to content

Metrics

Alex Peck edited this page Sep 18, 2022 · 7 revisions

Metrics are disabled by default for ConcurrentLru. By calling the builder method WithMetrics you can turn on metrics.

ICache<int, int> lru = new ConcurrentLruBuilder<int, int>()
   .WithMetrics()
   .Build();

For ConcurrentLfu metrics are always enabled since the buffered reads and writes mitigate any performance penalty.

To retrieve metrics from the cache, use the Metrics property.

Available metrics

  • Hit count
  • Miss count
  • Hit ratio
  • Eviction count
  • Update count

Under the hood

Internally metrics are implemented using the Counter class. This is a .NET implementation of Java's LongAdder. This is a scalable counter class with very high concurrent throughput.