首页 > 编程语言 > 详细

spring-boot-starter-cache设置

时间:2021-06-06 13:26:03      阅读:9      评论:0      收藏:0      [点我收藏+]

一、SpringBoot 2.x的配置方法;
1、通过spring-boot-starter-cache导入依赖;
2、spring-boot-autoconfigureCache的CacheAutoConfiguration负责全局的cache管理,RedisCacheConfiguration负责redis cache的配置;
3、RedisCacheConfiguration内有@Bean public RedisCacheManager cacheManager()方法,通过6个入参来设置RedisCacheManager;
4、一般我们通过两个入参来控制RedisCacheManager的构建:

  • ObjectProvider<org.springframework.data.redis.cache.RedisCacheConfiguration> redisCacheConfiguration
  • ObjectProvider redisCacheManagerBuilderCustomizers

5、相关链接:spring-boot-redis-cachehow-to-create-rediscachemanager-in-spring-data-2-0-x

二、SpringBoot 1.x的配置方法;
1、第一步相同;
2、第二步相同;
3、RedisCacheConfiguration内有@Bean public RedisCacheManager cacheManager(),通过入参RedisTemplate<Object, Object> redisTemplate来控制
4、我们在spring-boot-autoconfigureCache的RedisAutoConfiguration设置RedisTemplate

三、Jedis vs Lettuce和commons-pool2
1、1.x时默认为Jedis,2.x时默认为Lettuce(需要引入commons-pool2作为连接池);
2、如果2.x环境需要设置Jedis为默认Driver,可以参考 Use Jedis Instead of Lettuce

spring-boot-starter-cache设置

原文:https://www.cnblogs.com/echo1937/p/14854875.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!