Skip to content

Commit

Permalink
Merge pull request #656 from scireum/feature/SIRI-921_upgrade_jedis
Browse files Browse the repository at this point in the history
Upgrades Jedis library
  • Loading branch information
ymo-sci authored May 28, 2024
2 parents 94fc66c + ed02ae6 commit 9823a30
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.2.3</version>
<version>5.1.3</version>
<exclusions>
<exclusion>
<groupId>org.json</groupId>
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/sirius/db/redis/RedisDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

package sirius.db.redis;

import redis.clients.jedis.ClientSetInfoConfig;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
Expand Down Expand Up @@ -148,15 +151,24 @@ private synchronized Jedis setupConnection() {
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(maxActive);
jedisPoolConfig.setMaxIdle(maxIdle);

Tuple<String, Integer> effectiveHostAndPort = PortMapper.mapPort(determineServiceName(), host, port);
jedis = new JedisPool(jedisPoolConfig,
effectiveHostAndPort.getFirst(),
effectiveHostAndPort.getSecond(),
connectTimeout,
readTimeout,
Strings.isFilled(password) ? password : null,
db,
CallContext.getNodeName());
HostAndPort hostAndPort =
new HostAndPort(effectiveHostAndPort.getFirst(), effectiveHostAndPort.getSecond());

DefaultJedisClientConfig jedisClientConfig = DefaultJedisClientConfig.builder()
.database(db)
.clientName(CallContext.getNodeName())
.connectionTimeoutMillis(connectTimeout)
.socketTimeoutMillis(readTimeout)
.clientSetInfoConfig(new ClientSetInfoConfig(
true))
.password(Strings.isFilled(password) ?
password :
null)
.build();

jedis = new JedisPool(jedisPoolConfig, hostAndPort, jedisClientConfig);
}

return jedis.getResource();
Expand Down

0 comments on commit 9823a30

Please sign in to comment.