feat(java-cache): add CacheConfig.java (2/2)

This commit is contained in:
hoelee committed 2020-10-27 08:08:00 +08:00
1 parent 5eb810cfd9
commit aa16d3a377
1 file changed
+8
@@ -17,5 +17,13 @@ import org.springframework.context.annotation.Configuration;
public class CacheConfig {
@Bean
CacheManager cacheManager(CacheProperties properties) {
CaffeineCacheManager cacheManager = new CaffeineCacheManager("posts");
cacheManager.setCaffeine(Caffeine.newBuilder()
.recordStats()
.maximumSize(properties.maximumSize())
.expireAfterWrite(properties.ttl()));
return cacheManager;
}
}