From ead954a743516c33507e156f6c8fdaf030769739 Mon Sep 17 00:00:00 2001 From: "jot.zhao" Date: Fri, 9 Oct 2020 12:00:24 +0800 Subject: [PATCH] DATAREDIS-1231 - Use Jedis command routing if multiple BRPOP keys map to a single slot. Original pull request: #568. --- .../redis/connection/jedis/JedisClusterListCommands.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java index 77a5202c3..df51e1ed1 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java @@ -303,6 +303,14 @@ class JedisClusterListCommands implements RedisListCommands { Assert.notNull(keys, "Key must not be null!"); Assert.noNullElements(keys, "Keys must not contain null elements!"); + if (ClusterSlotHashUtil.isSameSlotForAllKeys(keys)) { + try { + return connection.getCluster().brpop(timeout,keys); + } catch (Exception ex) { + throw convertJedisAccessException(ex); + } + } + return connection.getClusterCommandExecutor() .executeMultiKeyCommand( (JedisMultiKeyClusterCommandCallback>) (client, key) -> client.brpop(timeout, key),