Lettuce
When we use Lettuce, we don’t need to configure the RedisConnectionFactory. Spring Boot does it for us.
All we have left, then, is to specify a few properties in our application.properties file:
1 2 3 4 5 6
| spring.redis.database=0 spring.redis.host=localhost spring.redis.port=16379 spring.redis.password=mypass
spring.redis.timeout=60000
|
jedis
- JedisConnectionFactory.setTimeout
ref: https://www.tabnine.com/code/java/methods/org.springframework.data.redis.connection.jedis.JedisConnectionFactory/setTimeout1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| @Bean public RedisConnectionFactory factory() { JedisConnectionFactory factory = new JedisConnectionFactory(); factory.setDatabase(dateBase); factory.setHostName(host); factory.setPort(port); factory.setPassword(password); JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxIdle(maxIdle); poolConfig.setMinIdle(minIdle); poolConfig.setMaxWaitMillis(maxWait); poolConfig.setMaxTotal(maxTotal); factory.setPoolConfig(poolConfig); factory.setTimeout(timeout); return factory; }
|