Search in sources :

Example 1 with CaffeineCache

use of com.yahoo.elide.datastores.aggregation.cache.CaffeineCache in project elide by yahoo.

the class ElideAutoConfiguration method buildQueryCache.

/**
 * Creates a query result cache to be used by {@link #buildDataStore}, or null if cache is to be disabled.
 * @param settings Elide configuration settings.
 * @return An instance of a query cache, or null.
 */
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "elide.aggregation-store.enabled", havingValue = "true")
public Cache buildQueryCache(ElideConfigProperties settings) {
    CaffeineCache cache = null;
    int maxCacheItems = settings.getAggregationStore().getQueryCacheMaximumEntries();
    if (maxCacheItems > 0) {
        cache = new CaffeineCache(maxCacheItems, settings.getAggregationStore().getDefaultCacheExpirationMinutes());
        if (meterRegistry != null) {
            CaffeineCacheMetrics.monitor(meterRegistry, cache.getImplementation(), "elideQueryCache");
        }
    }
    return cache;
}
Also used : CaffeineCache(com.yahoo.elide.datastores.aggregation.cache.CaffeineCache) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Aggregations

CaffeineCache (com.yahoo.elide.datastores.aggregation.cache.CaffeineCache)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)1 Bean (org.springframework.context.annotation.Bean)1