|  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import com.github.benmanes.caffeine.cache.Caffeine; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.cache.CacheManager; | 
 |  |  | import org.springframework.cache.caffeine.CaffeineCacheManager; | 
 |  |  | import org.springframework.context.annotation.Bean; | 
 |  |  | 
 |  |  |       maximumSize和maximumWeight不可以同时使用 | 
 |  |  |       weakValues和softValues不可以同时使用weakValues和softValues不可以同时使用 | 
 |  |  |      */ | 
 |  |  |  | 
 |  |  |     @Value("${pms.global.ssoUserExpireAfterAccess:60}") | 
 |  |  |     private Integer defaultTrueRandomFalsePassword; | 
 |  |  |     @Value("${pms.global.ssoCacheSizeInit:10}") | 
 |  |  |     private Integer ssoCacheSizeInit; | 
 |  |  |     @Value("${pms.global.ssoCacheSizeMax:10000}") | 
 |  |  |     private Integer ssoCacheSizeMax; | 
 |  |  |  | 
 |  |  |     @Bean | 
 |  |  |     public CacheManager cacheManager() { | 
 |  |  |         CaffeineCacheManager cacheManager = new CaffeineCacheManager(); | 
 |  |  |         cacheManager.setCaffeine(Caffeine.newBuilder() | 
 |  |  |                 .initialCapacity(10) | 
 |  |  |                 .maximumSize(10000) | 
 |  |  |                 .expireAfterAccess(30, TimeUnit.MINUTES)); | 
 |  |  |                 .initialCapacity(ssoCacheSizeInit) | 
 |  |  |                 .maximumSize(ssoCacheSizeMax) | 
 |  |  |                 .expireAfterAccess(defaultTrueRandomFalsePassword, TimeUnit.MINUTES)); | 
 |  |  |  | 
 |  |  |         return cacheManager; | 
 |  |  |     } |