zoukankan      html  css  js  c++  java
  • 聊聊spring-boot-starter-data-redis的配置变更

    本文主要研究一下spring-boot-starter-data-redis的配置变更

    配置变更

    以前是spring-boot的1.4.x版本的(spring-data-redis为1.7.x版本),最近切到2.0.4.RELEASEB版本(spring-data-redis为2.0.5.RELEASE版本),发现配置有变更。

    旧版配置

    spring.redis.database=0
    spring.redis.host=192.168.99.100
    spring.redis.port=6379
    #spring.redis.password= # Login password of the redis server.
    spring.redis.pool.max-active=8
    spring.redis.pool.max-idle=8
    spring.redis.pool.max-wait=-1
    spring.redis.pool.min-idle=0
    #spring.redis.sentinel.master= # Name of Redis server.
    #spring.redis.sentinel.nodes= # Comma-separated list of host:port pairs.
    spring.redis.timeout=10

    新版本配置

    spring.redis.database=0
    spring.redis.host=192.168.99.100
    spring.redis.port=6379
    #spring.redis.password= # Login password of the redis server.
    spring.redis.lettuce.pool.max-active=8
    spring.redis.lettuce.pool.max-idle=8
    spring.redis.lettuce.pool.max-wait=-1ms
    spring.redis.lettuce.pool.min-idle=0
    #spring.redis.sentinel.master= # Name of Redis server.
    #spring.redis.sentinel.nodes= # Comma-separated list of host:port pairs.
    spring.redis.timeout=100ms

    小结

    新版spring-boot-starter-data-redis有几个变更如下:

    • spring.redis底下除了公共的配置外,区分两个不同的实现,jedis及lettuce
    • 公共配置spring.redis.timeout的参数改为Duration类型,需要增加时间单位参数
    • spring-boot-starter-data-redis新版默认是使用lettuce
    • redis连接池需要引入commons-pool2类库,由于该类库新版本的一些核心类有变动,因此需要注意下版本号,超过2.4.3版本的可能会有问题
  • 相关阅读:
    c#冒泡排序算法和快速排序算法
    sqlserver 索引
    varchar和Nvarchar区别
    trigger
    sql语句
    超实用压力测试工具-ab工具
    js 页面离开前触发事件
    C# websocket与html js实现文件发送与接收处理
    C# socket编程 使用fleck轻松实现对话 https://github.com/statianzo/Fleck
    C# socket编程 使用udp实现单对单的连接对话
  • 原文地址:https://www.cnblogs.com/zhuyeshen/p/11428938.html
Copyright © 2011-2022 走看看