Hash keys using Jedis locally rather than call cluster keyslot.
Changing the remaining commands in JedisClusterKeyCommands to use the topology's getKeyServingMasterNode to find the node of key, rather than calling connection.clusterGetNodeForKey. clusterGetNodeForKey was making a cluster keyslot call to the server to hash the key, rather than hashing it locally. Closes: #2156 Original pull request: #2159.
This commit is contained in:
@@ -54,6 +54,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @author ihaohong
|
||||
* @author Dan Smith
|
||||
* @since 2.0
|
||||
*/
|
||||
class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
@@ -512,7 +513,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
return JedisConverters.toString(this.connection.execute("RESTORE", key,
|
||||
Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes("REPLACE"))));
|
||||
|
||||
}, connection.clusterGetNodeForKey(key));
|
||||
}, connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -595,7 +596,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.objectEncoding(key),
|
||||
connection.clusterGetNodeForKey(key))
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
.mapValue(JedisConverters::toEncoding);
|
||||
}
|
||||
|
||||
@@ -611,7 +612,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectIdletime(key),
|
||||
connection.clusterGetNodeForKey(key))
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
.mapValue(Converters::secondsToDuration);
|
||||
}
|
||||
|
||||
@@ -627,7 +628,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectRefcount(key),
|
||||
connection.clusterGetNodeForKey(key))
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
.getValue();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user