| | |
| | | |
| | | @Configuration |
| | | public class CaffeineCacheConfiguration { |
| | | private static final int cacheInitialCapacityDefault = 10 ; |
| | | private static final int cacheMaximumSizeDefault = 10000 ; |
| | | private static final int cacheDurationDefault = 720 ; |
| | | |
| | | @Value("${pipIrr.sso.cacheMaximumSize}") |
| | | private String cacheMaximumSize ; |
| | |
| | | */ |
| | | @Bean |
| | | public CacheManager cacheManager() { |
| | | int cacheMaximumSizeInt = 10000 ; |
| | | int cacheDurationInt = 720 ; |
| | | int cacheMaximumSizeInt; |
| | | int cacheDurationInt; |
| | | if(NumUtil.isPlusIntNumber(cacheMaximumSize)){ |
| | | cacheMaximumSizeInt = Integer.parseInt(cacheMaximumSize) ;// |
| | | cacheMaximumSizeInt = Integer.parseInt(cacheMaximumSize) ; |
| | | }else{ |
| | | cacheMaximumSizeInt = cacheMaximumSizeDefault ; |
| | | } |
| | | if(NumUtil.isPlusIntNumber(cacheDuration)){ |
| | | cacheDurationInt = Integer.parseInt(cacheDuration) ;// |
| | | cacheDurationInt = Integer.parseInt(cacheDuration) ; |
| | | }else{ |
| | | cacheDurationInt = cacheDurationDefault ; |
| | | } |
| | | CaffeineCacheManager cacheManager = new CaffeineCacheManager(); |
| | | cacheManager.setCaffeine(Caffeine.newBuilder() |
| | | .initialCapacity(10) |
| | | .initialCapacity(cacheInitialCapacityDefault) |
| | | .maximumSize(cacheMaximumSizeInt) |
| | | .expireAfterAccess(cacheDurationInt, TimeUnit.MINUTES)); |
| | | |