Commit a983316e640525911d33b9a2f4f7b78349ada4fa

Authored by Andrew Shvayka
1 parent e9d7561f

Initalizing Cache library

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