com.osomapps.pt.config.CachingConfig   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 23
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A cacheManager() 0 20 1
1
package com.osomapps.pt.config;
2
3
import com.google.common.cache.CacheBuilder;
4
import java.util.Arrays;
5
import java.util.concurrent.TimeUnit;
6
import org.springframework.cache.CacheManager;
7
import org.springframework.cache.annotation.EnableCaching;
8
import org.springframework.cache.concurrent.ConcurrentMapCache;
9
import org.springframework.cache.support.SimpleCacheManager;
10
import org.springframework.context.annotation.Bean;
11
import org.springframework.context.annotation.Configuration;
12
import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;
13
14
@Configuration
15
@EnableCaching
16
@EnableJdbcHttpSession(tableName = "ptcore.SPRING_SESSION")
17
class CachingConfig {
18
19
    @Bean
20
    CacheManager cacheManager() {
21
        final SimpleCacheManager cacheManager = new SimpleCacheManager();
22
        cacheManager.setCaches(
23
                Arrays.asList(
24
                        new ConcurrentMapCache(
25
                                "dictionaryData",
26
                                CacheBuilder.newBuilder()
27
                                        .expireAfterWrite(1, TimeUnit.DAYS)
28
                                        .build()
29
                                        .asMap(),
30
                                false),
31
                        new ConcurrentMapCache(
32
                                "dictionaryAllData",
33
                                CacheBuilder.newBuilder()
34
                                        .expireAfterWrite(1, TimeUnit.DAYS)
35
                                        .build()
36
                                        .asMap(),
37
                                false)));
38
        return cacheManager;
39
    }
40
}
41