当前位置: 首页 > news >正文

网站建设需要的职位软件开发培训机构加盟

网站建设需要的职位,软件开发培训机构加盟,网上服装商城网站建设方案策划书,玉林建设信息网站引入依赖 建议使用 Lettuce 连接驱动 !--一#xff1a;Jedis连接驱动缺点#xff1a;Jedis基于TCP的阻塞性的连接方式1. 阻塞性IO2. 不能异步3. 线程不安全的Lettuce连接驱动优点#xff1a;Lettuce基于Netty的多路复用的异步非阻塞的连接方式#xff0c;1. 线程安全2…引入依赖 建议使用 Lettuce 连接驱动 !--一Jedis连接驱动缺点Jedis基于TCP的阻塞性的连接方式1. 阻塞性IO2. 不能异步3. 线程不安全的Lettuce连接驱动优点Lettuce基于Netty的多路复用的异步非阻塞的连接方式1. 线程安全2. 基于Netty框架的事件驱动通信可以异步的3. 适合于分布式的缓存。二Springboot 1.x 默认redis驱动使用JedisSpringboot 2.x 默认redis驱动使用LettuceJedis驱动使用连接池是 commons-pool2Lettuce驱动使用连接池也是 commons-pool2--!-- Redis --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-redis/artifactId/dependency!-- 显式导入 commons-pool2 连接池 --dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-pool2/artifactId/dependency配置文件 spring:redis:# 集群cluster:# 集群地址nodes:redis:7000,redis:7001,redis:7002,redis:7003,redis:7004,redis:7005 # redis换成ip# 连接驱动lettuce:# 连接池配置pool:# 最大空闲连接max-idle: 8# 最大连接数max-active: 8# 最小空闲连接min-idle: 2# 最大建立连接等待时间max-wait: 1ms配置类 配置文件读取类 ConfigurationProperties(prefix spring.redis.cluster) Component Data public class RedisProperties {// 集群节点列表private String nodes;}/*** Redis连接池配置信息读取类*/ Component ConfigurationProperties(prefix spring.redis.lettuce.pool) Data public class RedisPoolProperties {// 最大空闲连接private Integer maxIdle;// 最小空闲连接private Integer minIdle;// 最大连接数private Integer maxActive;// 最大建立连接等待时间private Duration maxWait; }配置文件Config Configuration public class RedisConfig {// Redis配置信息读取类Resourceprivate RedisProperties redisProperties;// 连接池配置信息读取类Resourceprivate RedisPoolProperties redisPoolProperties;Beanpublic RedisTemplateString, Object redisTemplate() {RedisTemplateString, Object redisTemplate new RedisTemplate();// key,value序列化配置/* ************************ 常用的RedisSerializer** 1. Jackson2JsonRedisSerializer* 2. GenericFastJsonRedisSerializer 或 FastJsonRedisSerializer (fastJson2)* 3. StringRedisSerializer (只能支持String)* *********************/redisTemplate.setKeySerializer(new StringRedisSerializer());redisTemplate.setValueSerializer(new GenericFastJsonRedisSerializer());// 连接驱动的配置redisTemplate.setConnectionFactory(lettuceConnectionFactory());return redisTemplate;}/*** Lettuce连接驱动的配置*/Beanpublic LettuceConnectionFactory lettuceConnectionFactory() {// redis集群的配置MapString, Object map new HashMap();map.put(spring.redis.cluster.nodes, redisProperties.getNodes());RedisClusterConfiguration redisClusterConfiguration new RedisClusterConfiguration(new MapPropertySource(RedisClusterConfiguration,map));/* ************************ redis集群方式的不同需要使用对应的Redis配置实现类** RedisClusterConfiguration: 集群* RedisSentinelConfiguration 哨兵* RedisStandaloneConfiguration单机** *********************/// Lettuce连接池的配置GenericObjectPoolConfig genericObjectPoolConfig new GenericObjectPoolConfig();genericObjectPoolConfig.setMaxWait(redisPoolProperties.getMaxWait());genericObjectPoolConfig.setMinIdle(redisPoolProperties.getMinIdle());genericObjectPoolConfig.setMaxTotal(redisPoolProperties.getMaxActive());genericObjectPoolConfig.setMaxWait(redisPoolProperties.getMaxWait());LettucePoolingClientConfiguration lettucePoolingClientConfiguration LettucePoolingClientConfiguration.builder().poolConfig(genericObjectPoolConfig).build();return new LettuceConnectionFactory(redisClusterConfiguration,lettucePoolingClientConfiguration);} }工具类 /*** Redis工具类*/ Component public class RedisUtil {Resourceprivate RedisTemplateString, Object redisTemplate;public void stringSet(String key, Object value) {redisTemplate.opsForValue().set(key, value);}public Object stringGet(String key) {return redisTemplate.opsForValue().get(key);}public void hashSet(String key, MapString, Object map) {redisTemplate.opsForHash().putAll(key, map);}public Object hashGet(String key, String hashKey) {return redisTemplate.opsForHash().get(key, hashKey);} }
http://www.sadfv.cn/news/414837/

相关文章:

  • 具有营销型网站的公司精美旅游网站案例
  • 建立网站小程序教育机构网站代码
  • 企业网站设计论文导航网站制作教程
  • 落伍者论坛 做网站公众号同步到dede网站
  • 滤芯网站怎么做电商网络运营
  • 百川网站维护html简单网页
  • 做网站包含微信公众号吗to a wordpress
  • 泰安网站建设收益天津建设网查询
  • 网上写作最好的网站兰州网站seo收费标准
  • 一个空间如何做多个网站wordpress专业开发指南
  • 互联网站备案信息wordpress安装后查看站点失败
  • 沧州网站制作公司工业设计公司简介
  • iis7添加网站江西城市建设管理协会网站
  • 网站改版的好处玉林建设工程信息网站
  • 登录广东省建设监理协会网站首页定制高端网站
  • 熊撑号怎么做网站推广企业年检网上申报
  • 闵行集团网站建设wordpress大前端d8
  • 做企业网站建设公司哪家好口碑推广
  • 网站开发公司联系电话网站主页制作教程
  • 商务网站开发文档做网站应该考虑哪些问题
  • 做班级网站的目的广东网站备案要多久
  • 大连市平台网站杭州住房和城乡建设厅官网
  • 漯河网站网站建设wordpress简繁转换
  • 长安网站建设软件什么是品牌型网站
  • 淄博天一建设项目招标代理有限公司网站哪里有做阿里网站的
  • 常德政务网站wordpress登录查看插件
  • 做企业网站一般多少钱新手学做网站优化
  • 查询建筑企业网站百度一下你就知道移动官网
  • 建立网站要花多少钱宣传型电子商务网站
  • 单位网站设计建议书北京宣传片制作公司