Skip to content

Commit

Permalink
Fix recording of cache metrics [KVL-888] (digital-asset#9382)
Browse files Browse the repository at this point in the history
* Fix recording of cache metrics.
CHANGELOG_BEGIN
CHANGELOG_END

* Removed unused imports.

* Code tidying.
  • Loading branch information
miklos-da authored Apr 13, 2021
1 parent 67b0e2b commit 29fcebe
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ object CaffeineCache {
def apply[Key <: AnyRef, Value <: AnyRef](
builder: caffeine.Caffeine[_ >: Key, _ >: Value],
metrics: Option[CacheMetrics],
): ConcurrentCache[Key, Value] = {
val cache = builder.build[Key, Value]
): ConcurrentCache[Key, Value] =
metrics match {
case None => new SimpleCaffeineCache(cache)
case Some(metrics) => new InstrumentedCaffeineCache(cache, metrics)
case None => new SimpleCaffeineCache(builder.build[Key, Value])
case Some(metrics) =>
builder.recordStats(() => new DropwizardStatsCounter(metrics))
new InstrumentedCaffeineCache(builder.build[Key, Value], metrics)
}
}

private final class SimpleCaffeineCache[Key <: AnyRef, Value <: AnyRef](
cache: caffeine.Cache[Key, Value]
Expand Down

0 comments on commit 29fcebe

Please sign in to comment.