跳至主要内容

博文

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

Caching with Redis

Spring Caching with Redis Spring Data Redis   project provide an CacheManager implementation for Redis. Get Redis Get a copy of Redis from   official Redis website . In most of linux distribution, you can install it from distribution repository directly. Before you run you codes, make sure it is running. 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, configure a Redis specific   CacheManager . @Override @Bean public CacheManager cacheManager() { RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate()); return cacheManager; } @Bean public RedisTemplate redisTemplate() { RedisTemplate redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); return redisTemplate; } @Bean public JedisConnection...