1.创建Cache配置类
@Configuration@EnableCachingpublic class RedisCacheConfig extends CachingConfigurerSupport { @Value("${redis.cache.expiration}") private Long expiration; /** * * 管理缓存 */ @Bean public CacheManager cacheManager(RedisTemplate
2.使用
1.手动方式:
Jedis工具类
@Componentpublic class RedisUtil { private Logger log = LoggerFactory.getLogger(getClass()); @Autowired private StringRedisTemplate stringRedisTemplate; @Autowired private RedisTemplate
2.自动方式:
添加@Cacheable注解实现缓存添加
添加@CacheEvict注解实现缓存删除
具体实现参考上一篇文章:
转载地址:https://blog.csdn.net/weixin_30616969/article/details/98701561 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!