Talk about the configuration changes of spring-boot-starter-data-redis.

  redis

Order

This article mainly studies the configuration changes of spring-boot-starter-data-redis.

Configuration change

Previously, it was version 1.4.x of spring-boot (spring-data-redis is version 1.7.x). Recently, it was cut to version 2.0.4.RELEASEB (spring-data-redis is version 2.0.5.RELEASE). It was found that there were configuration changes.

Legacy configuration

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

New version configuration

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

Summary

The new spring-boot-starter-data-redis has several changes as follows:

  • Spring.redis distinguishes two different implementations, jedis and lettuce, in addition to the common configuration
  • The parameter of public configuration spring.redis.timeout is changed to Duration type, and the time unit parameter needs to be added.
  • Spring-boot-starter-data-redis new edition uses lettuce by default.
  • Redis connection pool needs to introduce commons-pool2 class library. due to changes in some core classes in the new version of the class library, it is necessary to pay attention to the following version number. there may be problems beyond version 2.4.3

doc