DATAREDIS-694 - Polishing.

Adapt Lettuce implementation to use async commands in transaction mode. Adapt tests to changed behavior of returning status responses. Extend Javadoc.

Original pull request: #284.
This commit is contained in:
Mark Paluch
2017-11-02 11:21:39 +01:00
parent 8a640a29b6
commit 941b448072
3 changed files with 11 additions and 10 deletions

View File

@@ -177,14 +177,17 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
} }
/** /**
* Execute the given command for the {@code key} provided potentially appending args. <br /> * Execute the given command for each key in {@code keys} provided appending all {@code args} on each invocation.
* <br />
* This method, other than {@link #execute(String, byte[]...)}, dispatches the command to the {@code key} serving * This method, other than {@link #execute(String, byte[]...)}, dispatches the command to the {@code key} serving
* master node. * master node and appends the {@code key} as first command argument to the {@code command}. {@code keys} are not
* required to share the same slot for single-key commands. Multi-key commands carrying their keys in {@code args}
* still require to share the same slot as the {@code key}.
* *
* <pre> * <pre>
* <code> * <code>
* // SET foo bar EX 10 NX * // SET foo bar EX 10 NX
* execute("SET", "foo".getBytes(), asBinaryList("bar", "EX", 10, "NX") * execute("SET", "foo".getBytes(), asBinaryList("bar", "EX", 10, "NX"))
* </code> * </code>
* </pre> * </pre>
* *
@@ -860,7 +863,8 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
PropertyAccessor accessor = new DirectFieldAccessFallbackBeanWrapper(cluster); PropertyAccessor accessor = new DirectFieldAccessFallbackBeanWrapper(cluster);
this.connectionHandler = accessor.isReadableProperty("connectionHandler") this.connectionHandler = accessor.isReadableProperty("connectionHandler")
? (JedisClusterConnectionHandler) accessor.getPropertyValue("connectionHandler") : null; ? (JedisClusterConnectionHandler) accessor.getPropertyValue("connectionHandler")
: null;
} else { } else {
this.connectionHandler = null; this.connectionHandler = null;
} }

View File

@@ -165,7 +165,7 @@ class LettuceKeyCommands implements RedisKeyCommands {
return null; return null;
} }
if (isQueueing()) { if (isQueueing()) {
transaction(connection.newLettuceTxResult(getConnection().touch(keys))); transaction(connection.newLettuceResult(getAsyncConnection().touch(keys)));
return null; return null;
} }
return getConnection().touch(keys); return getConnection().touch(keys);

View File

@@ -69,9 +69,7 @@ import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.types.Expiration; import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.core.types.RedisClientInfo; import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.data.redis.test.util.RedisClientRule; import org.springframework.data.redis.test.util.RedisClientRule;
import org.springframework.data.redis.test.util.RedisDriver; import org.springframework.data.redis.test.util.RedisDriver;
import org.springframework.data.redis.test.util.WithRedisDriver; import org.springframework.data.redis.test.util.WithRedisDriver;
@@ -2778,11 +2776,10 @@ public abstract class AbstractConnectionIntegrationTests {
@Test // DATAREDIS-694 @Test // DATAREDIS-694
public void touchReturnsNrOfKeysTouched() { public void touchReturnsNrOfKeysTouched() {
connection.set("touch.this", "Can't touch this! - oh-oh oh oh oh-oh-oh"); actual.add(connection.set("touch.this", "Can't touch this! - oh-oh oh oh oh-oh-oh"));
actual.add(connection.touch("touch.this", "touch.that")); actual.add(connection.touch("touch.this", "touch.that"));
verifyResults(Arrays.asList(new Object[] { 1L })); verifyResults(Arrays.asList(new Object[] { Boolean.TRUE, 1L }));
} }
@Test // DATAREDIS-694 @Test // DATAREDIS-694