跳至主要内容

博文

目前显示的是标签为“Guava”的博文

Caching with Google Guava

Spring Caching with Guava In Spring core, it also provides Guava Cache support. Enable Caching Add   @EnableCaching(mode=AdviceMode.ASPECTJ)   annotation on the configuration class if you are using Java based configuration. @Configuration ... @EnableCaching(mode=AdviceMode.ASPECTJ) public class JpaConfig {...} Then, specify a   CacheManager   provider in your configuration. There is a   GuavaCacheManager   provided by Spring. @Override @Bean public CacheManager cacheManager() { return new GuavaCacheManager(); } @Override @Bean public KeyGenerator keyGenerator() { return new SimpleKeyGenerator(); } Do not forget to add the   guava   dependency in your Maven pom.xml file. <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> Code sample Check out the sample codes. https://github.com/hantsy/spring-sandbox4 And explore the   spring-cache-guava...