DATAREDIS-588 - Use JedisCluster.psetex(…) instead dispatching to a node.

We now use JedisCluster's psetex command instead of looking up the topology and dispatching the command ourselves.

Original Pull Request: #463
This commit is contained in:
Mark Paluch
2019-06-28 13:24:17 +02:00
committed by Christoph Strobl
parent 15fd1d38de
commit 7f9aca031a
2 changed files with 8 additions and 9 deletions

View File

@@ -33,7 +33,6 @@ import org.springframework.data.redis.connection.BitFieldSubCommands;
import org.springframework.data.redis.connection.ClusterSlotHashUtil;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.connection.jedis.JedisClusterConnection.JedisClusterCommandCallback;
import org.springframework.data.redis.connection.jedis.JedisClusterConnection.JedisMultiKeyClusterCommandCallback;
import org.springframework.data.redis.connection.lettuce.LettuceConverters;
import org.springframework.data.redis.core.types.Expiration;
@@ -189,11 +188,11 @@ class JedisClusterStringCommands implements RedisStringCommands {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
return Converters.stringToBoolean(connection.getClusterCommandExecutor()
.executeCommandOnSingleNode(
(JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value),
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
.getValue());
try {
return Converters.stringToBoolean(connection.getCluster().psetex(key, milliseconds, value));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
/*

View File

@@ -1836,9 +1836,9 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
nativeConnection.set(KEY_1_BYTES, VALUE_1_BYTES);
clusterConnection.set(KEY_1_BYTES, VALUE_2_BYTES, Expiration.persistent(), SetOption.ifPresent());
assertThat(nativeConnection.exists(KEY_1_BYTES), is(true));
assertThat(clusterConnection.get(KEY_1_BYTES), is(VALUE_2_BYTES));
assertThat(nativeConnection.ttl(KEY_1_BYTES), is(-1L));
assertThat(nativeConnection.exists(KEY_1_BYTES)).isTrue();
assertThat(clusterConnection.get(KEY_1_BYTES)).isEqualTo(VALUE_2_BYTES);
assertThat(nativeConnection.ttl(KEY_1_BYTES)).isEqualTo(-1L);
}
@Test // DATAREDIS-315