| 22009 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.config;
|
|
|
2 |
|
|
|
3 |
import java.util.concurrent.TimeUnit;
|
|
|
4 |
|
|
|
5 |
import org.springframework.cache.CacheManager;
|
|
|
6 |
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
|
|
7 |
import org.springframework.cache.annotation.EnableCaching;
|
|
|
8 |
import org.springframework.cache.guava.GuavaCacheManager;
|
|
|
9 |
import org.springframework.context.annotation.Bean;
|
|
|
10 |
import org.springframework.context.annotation.Configuration;
|
|
|
11 |
|
|
|
12 |
import com.google.common.cache.CacheBuilder;
|
|
|
13 |
|
|
|
14 |
@Configuration
|
|
|
15 |
@EnableCaching
|
|
|
16 |
public class CacheConfig extends CachingConfigurerSupport{
|
|
|
17 |
@Override
|
|
|
18 |
|
|
|
19 |
@Bean
|
|
|
20 |
public CacheManager cacheManager() {
|
|
|
21 |
GuavaCacheManager cacheManager = new GuavaCacheManager();
|
|
|
22 |
return cacheManager;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
@Bean
|
|
|
26 |
public CacheManager timeoutCacheManager() {
|
|
|
27 |
GuavaCacheManager cacheManager = new GuavaCacheManager();
|
|
|
28 |
CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder()
|
|
|
29 |
.maximumSize(100)
|
|
|
30 |
.expireAfterWrite(5, TimeUnit.MINUTES);
|
|
|
31 |
cacheManager.setCacheBuilder(cacheBuilder);
|
|
|
32 |
return cacheManager;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
}
|