Commit a983316e640525911d33b9a2f4f7b78349ada4fa

Authored by Andrew Shvayka
1 parent e9d7561f

Initalizing Cache library

1 /** 1 /**
2 * Copyright © 2016-2018 The Thingsboard Authors 2 * Copyright © 2016-2018 The Thingsboard Authors
3 - * 3 + * <p>
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - * 7 + * <p>
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + * <p>
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,8 +16,10 @@ @@ -16,8 +16,10 @@
16 package org.thingsboard.server.dao.cache; 16 package org.thingsboard.server.dao.cache;
17 17
18 import com.github.benmanes.caffeine.cache.Caffeine; 18 import com.github.benmanes.caffeine.cache.Caffeine;
  19 +import com.github.benmanes.caffeine.cache.RemovalCause;
19 import com.github.benmanes.caffeine.cache.Ticker; 20 import com.github.benmanes.caffeine.cache.Ticker;
20 import lombok.Data; 21 import lombok.Data;
  22 +import lombok.extern.slf4j.Slf4j;
21 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 23 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
22 import org.springframework.boot.context.properties.ConfigurationProperties; 24 import org.springframework.boot.context.properties.ConfigurationProperties;
23 import org.springframework.cache.CacheManager; 25 import org.springframework.cache.CacheManager;
@@ -28,6 +30,7 @@ import org.springframework.cache.support.SimpleCacheManager; @@ -28,6 +30,7 @@ import org.springframework.cache.support.SimpleCacheManager;
28 import org.springframework.context.annotation.Bean; 30 import org.springframework.context.annotation.Bean;
29 import org.springframework.context.annotation.Configuration; 31 import org.springframework.context.annotation.Configuration;
30 32
  33 +import java.util.Arrays;
31 import java.util.List; 34 import java.util.List;
32 import java.util.Map; 35 import java.util.Map;
33 import java.util.concurrent.TimeUnit; 36 import java.util.concurrent.TimeUnit;
@@ -38,12 +41,14 @@ import java.util.stream.Collectors; @@ -38,12 +41,14 @@ import java.util.stream.Collectors;
38 @ConfigurationProperties(prefix = "caffeine") 41 @ConfigurationProperties(prefix = "caffeine")
39 @EnableCaching 42 @EnableCaching
40 @Data 43 @Data
  44 +@Slf4j
41 public class CaffeineCacheConfiguration { 45 public class CaffeineCacheConfiguration {
42 46
43 private Map<String, CacheSpecs> specs; 47 private Map<String, CacheSpecs> specs;
44 48
45 @Bean 49 @Bean
46 public CacheManager cacheManager() { 50 public CacheManager cacheManager() {
  51 + log.trace("Initializing cache: {}", Arrays.toString(RemovalCause.values()));
47 SimpleCacheManager manager = new SimpleCacheManager(); 52 SimpleCacheManager manager = new SimpleCacheManager();
48 if (specs != null) { 53 if (specs != null) {
49 List<CaffeineCache> caches = 54 List<CaffeineCache> caches =