Skip to content

Commit

Permalink
DATAREDIS-1231 - Use Jedis command routing if multiple BRPOP keys map…
Browse files Browse the repository at this point in the history
… to a single slot.

Original pull request: #568.
  • Loading branch information
jotzhao authored and mp911de committed Oct 13, 2020
1 parent 41136c6 commit ead954a
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -303,6 +303,14 @@ public List<byte[]> bRPop(int timeout, byte[]... keys) {
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<List<byte[]>>) (client, key) -> client.brpop(timeout, key),
Expand Down

0 comments on commit ead954a

Please sign in to comment.