SpringBoot2.0默认使用Redis连接池的配置注意事项
SpringBoot2.0默认采用Lettuce客户端来连接Redis服务端的
默认是不使用连接池的,只有配置 redis.lettuce.pool下的属性的时候才可以使用到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 # 连接池中的最小空闲连接
没有这个配置时
增加这个配置时
同时,使用连接池,要依赖commons-pool2
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
如果没有引入,会报错