cacheManager()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 20
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 20
rs 9.4
c 0
b 0
f 0
cc 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