public CacheConfigurationBuilder createCacheConfiguration() {
    LOG.info("Creating Metrics Cache with timeouts => ttl = " +
      configuration.getMetricCacheTTLSeconds() + ", idle = " +
      configuration.getMetricCacheIdleSeconds() + ", cache size = " + configuration.getMetricCacheEntryUnitSize());

    TimelineMetricCacheCustomExpiry timelineMetricCacheCustomExpiry = new TimelineMetricCacheCustomExpiry(
            Duration.ofSeconds(configuration.getMetricCacheTTLSeconds()),
            Duration.ofSeconds(configuration.getMetricCacheIdleSeconds())
    );

    CacheConfigurationBuilder<TimelineAppMetricCacheKey, TimelineMetricsCacheValue> cacheConfigurationBuilder = CacheConfigurationBuilder
            .newCacheConfigurationBuilder(
                    TimelineAppMetricCacheKey.class,
                    TimelineMetricsCacheValue.class,
                    ResourcePoolsBuilder.newResourcePoolsBuilder()
                    .heap(configuration.getMetricCacheEntryUnitSize(), EntryUnit.ENTRIES)
            )
            .withKeySerializer(TimelineAppMetricCacheKeySerializer.class)
            .withValueSerializer(TimelineMetricsCacheValueSerializer.class)
            .withLoaderWriter(cacheEntryFactory)
            .withExpiry(timelineMetricCacheCustomExpiry);

    return cacheConfigurationBuilder;
  }
Cache implementation that provides ability to perform incremental reads
from Metrics backend and reduce the amount of calls between Ambari and the
Metrics backend.
ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/cache/TimelineMetricCacheProvider.java