Skip to content

Commit 8551281

Browse files
authored
Merge pull request #50760 from Ladicek/redis-client-topology-cache-ttl
Redis Client: add sentinel topology cache TTL configuration
2 parents 1b6e363 + b78eca4 commit 8551281

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/VertxRedisClientFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ public void accept(Set<URI> uris) {
100100
options.setPassword(config.password().orElse(null));
101101
config.poolCleanerInterval().ifPresent(d -> options.setPoolCleanerInterval((int) d.toMillis()));
102102
config.poolRecycleTimeout().ifPresent(d -> options.setPoolRecycleTimeout((int) d.toMillis()));
103-
options.setHashSlotCacheTTL(config.hashSlotCacheTtl().toMillis());
103+
// the Vert.x Redis client will only unify `topologyCacheTTL` and `hashSlotCacheTTL` in version 5.1,
104+
// but in Quarkus, we unify them already
105+
long topologyCacheTtl = config.topologyCacheTtl().orElse(config.hashSlotCacheTtl()).toMillis();
106+
options.setHashSlotCacheTTL(topologyCacheTtl);
107+
options.setTopologyCacheTTL(topologyCacheTtl);
104108

105109
config.role().ifPresent(options::setRole);
106110
options.setType(config.clientType());

extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/client/config/RedisClientConfig.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,23 @@ public interface RedisClientConfig {
148148
Optional<ProtocolVersion> preferredProtocolVersion();
149149

150150
/**
151-
* The TTL of the hash slot cache. A hash slot cache is used by the clustered Redis client
152-
* to prevent constantly sending {@code CLUSTER SLOTS} commands to the first statically
153-
* configured cluster node.
154-
* <p>
155-
* This setting is only meaningful in case of a clustered Redis client and has no effect
156-
* otherwise.
151+
* @deprecated use {@code quarkus.redis.topology-cache-ttl}
157152
*/
153+
@Deprecated(forRemoval = true, since = "3.30")
158154
@WithDefault("1s")
159155
Duration hashSlotCacheTtl();
160156

157+
/**
158+
* The TTL of the topology cache. A topology cache is used by a clustered Redis client
159+
* and a sentinel Redis client to prevent constantly sending topology discovery commands
160+
* ({@code CLUSTER SLOTS} or {@code SENTINEL ...}).
161+
* <p>
162+
* This setting is only meaningful in case of a clustered Redis client and a sentinel
163+
* Redis client and has no effect otherwise.
164+
*/
165+
@WithDefault("1s")
166+
Optional<Duration> topologyCacheTtl();
167+
161168
/**
162169
* Whether automatic failover is enabled. This only makes sense for sentinel clients
163170
* with role of {@code MASTER} and is ignored otherwise.

0 commit comments

Comments
 (0)