Initalizing Cache library
This commit is contained in:
		
							parent
							
								
									e9d7561fd8
								
							
						
					
					
						commit
						a983316e64
					
				@ -1,12 +1,12 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2018 The Thingsboard Authors
 | 
			
		||||
 *
 | 
			
		||||
 * <p>
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * <p>
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 * <p>
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
@ -16,8 +16,10 @@
 | 
			
		||||
package org.thingsboard.server.dao.cache;
 | 
			
		||||
 | 
			
		||||
import com.github.benmanes.caffeine.cache.Caffeine;
 | 
			
		||||
import com.github.benmanes.caffeine.cache.RemovalCause;
 | 
			
		||||
import com.github.benmanes.caffeine.cache.Ticker;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.cache.CacheManager;
 | 
			
		||||
@ -28,6 +30,7 @@ import org.springframework.cache.support.SimpleCacheManager;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
@ -38,12 +41,14 @@ import java.util.stream.Collectors;
 | 
			
		||||
@ConfigurationProperties(prefix = "caffeine")
 | 
			
		||||
@EnableCaching
 | 
			
		||||
@Data
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class CaffeineCacheConfiguration {
 | 
			
		||||
 | 
			
		||||
    private Map<String, CacheSpecs> specs;
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    public CacheManager cacheManager() {
 | 
			
		||||
        log.trace("Initializing cache: {}", Arrays.toString(RemovalCause.values()));
 | 
			
		||||
        SimpleCacheManager manager = new SimpleCacheManager();
 | 
			
		||||
        if (specs != null) {
 | 
			
		||||
            List<CaffeineCache> caches =
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user