lettuce

1
2
3
4
5
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.3.3.RELEASE</version>
</dependency>
阅读更多

webflux lettuce redis

1
2
3
4
5
6
7
8
9
 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
1
2
# Connect redis cluster nodes with – C parameter: redis cli – C – H 172.17.0.1 – P 6391
redis-cli –c -h 172.17.0.1 –p 6391
阅读更多

jedis/lettuce timeout

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
# timeout establishes the connection timeout
spring.redis.timeout=60000

jedis

  • JedisConnectionFactory.setTimeout
    ref: https://www.tabnine.com/code/java/methods/org.springframework.data.redis.connection.jedis.JedisConnectionFactory/setTimeout
    1
    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;
    }
阅读更多