连接池

MySQL连接池配置

spring:
    datasource:
        druid:
          driver-class-name: com.mysql.cj.jdbc.Driver
          url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
          username: root
          password: root
          # 初始化大小,最小,最大
          initial-size: 5
          max-active: 20
          min-idle: 3
          # 获取连接最大超时时间
          max-wait: 60000
          # 检测时间:配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
          time-between-eviction-runs-millis: 60000
          # 配置一个连接在池中最小生存的时间,单位是毫秒
          min-evictable-idle-time-millis: 300000 
          # 打开PSCache,并且指定每个连接上PSCache的大小
          pool-prepared-statements: true
          max-pool-prepared-statement-per-connection-size: 20
          # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
          connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000

 

Redis 连接池

redis:
    cluster:
      nodes: ${redis.host.cluster}
    password: ${redis.password}
    lettuce:
      shutdown-timeout: 100 # 关闭超时时间
      pool:
        max-active: 8 # 连接池最大连接数(使用负值表示没有限制)
        max-idle: 8 # 连接池中的最大空闲连接
        max-wait: 30 # 连接池最大阻塞等待时间(使用负值表示没有限制)
        min-idle: 0 # 连接池中的最小空闲连接

 

参考文章

【1】 springboot redis 连接池

posted @ 2024-05-26 15:42  先娶国王后取经  阅读(3)  评论(0编辑  收藏  举报