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
阅读更多

Grafana

使用Docker下载和运行Grafana

###下载Grafana

1
docker run -d --name=grafana -p 3000:3000 grafana/grafana

可以访问http://192.168.50.28:3000,并且使用默认的账户名(admin)密码(admin)来登录Grafana

阅读更多

java/spring 内存数据库

H2数据库

H2是一个由java实现的开源内存数据库,它可以支持内存模式和独立模式。 如果要使用H2数据库,需要添加如下依赖:

1
2
3
4
5
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.194</version>
</dependency>
阅读更多

spring mybatis-plus

pom.xml

1
2
3
4
5
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
阅读更多

Object Storage

ibm-cos-sdk-java

1
2
3
4
5
<dependency>
<groupId>com.ibm.cos</groupId>
<artifactId>ibm-cos-java-sdk</artifactId>
<version>2.11.1</version>
</dependency>
阅读更多

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;
    }
阅读更多