alibaba / alibaba/jetcache

jetcache连redis创建JedisPool时,默认使用连接超时时间赋值读超时时间

Open
#545 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

jetcache-starter-redis版本:2.5.14
yaml配置:
``` yaml
jetcache:
statIntervalMinutes: 60
areaInCacheName: false
remote:
default:
host: ***.**.**.***
password: ******
type: redis
keyConvertor: fastjson
valueEncoder: java
valueDecoder: java
timeout: 1000
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
```
RedisAutoConfiguration中创建jedispool时 ,调用的jedispool构造函数是用timeout值默认赋值读超时时间soTimeout
```java
private Pool parsePool(ConfigTree ct) {
GenericObjectPoolConfig poolConfig = parsePoolConfig(ct);

String host = ct.getProperty("host", (String) null);
int port = Integer.parseInt(ct.getProperty("port", "0"));
int timeout = Integer.parseInt(ct.getProperty("timeout", String.valueOf(Protocol.DEFAULT_TIMEOUT)));
String password = ct.getProperty("password", (String) null);
int database = Integer.parseInt(ct.getProperty("database", String.valueOf(Protocol.DEFAULT_DATABASE)));
String clientName = ct.getProperty("clientName", (String) null);
boolean ssl = Boolean.parseBoolean(ct.getProperty("ssl", "false"));

String masterName = ct.getProperty("masterName", (String) null);
String sentinels = ct.getProperty("sentinels", (String) null);//ip1:port,ip2:port

Pool jedisPool;
if (sentinels == null) {
Objects.requireNonNull(host, "host/port or sentinels/masterName is required");
if (port == 0) {
throw new IllegalStateException("host/port or sentinels/masterName is required");
}
jedisPool = new JedisPool(poolConfig, host, port, timeout, password, database, clientName, ssl);
} else {
Objects.requireNonNull(masterName, "host/port or sentinels/masterName is required");
String[] strings = sentinels.split(",");
HashSet sentinelsSet = new HashSet<>();
for (String s : strings) {
if (s != null && !s.trim().equals("")) {
sentinelsSet.add(s.trim());
}
}
jedisPool = new JedisSentinelPool(masterName, sentinelsSet, poolConfig, timeout, password, database, clientName);
}
return jedisPool;
}
```
配置项中是否可增加读超时的配置,此处创建时可以根据配置创建jedispool
否则想控制读超时时间 比较 麻烦

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at RedisAutoConfiguration.parsePool, focusing on the timeout read from ConfigTree and the JedisPool and JedisSentinelPool constructors shown in the issue. Trace the Redis configuration properties and existing tests, then verify that a separate read-timeout setting is honored while the current timeout behavior remains defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.