Skip to content

Commit 941b448

Browse files
committed
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.
1 parent 8a640a2 commit 941b448

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,17 @@ private static byte[][] getCommandArguments(byte[] key, Collection<byte[]> args)
177177
}
178178

179179
/**
180-
* Execute the given command for the {@code key} provided potentially appending args. <br />
180+
* Execute the given command for each key in {@code keys} provided appending all {@code args} on each invocation.
181+
* <br />
181182
* This method, other than {@link #execute(String, byte[]...)}, dispatches the command to the {@code key} serving
182-
* master node.
183+
* master node and appends the {@code key} as first command argument to the {@code command}. {@code keys} are not
184+
* required to share the same slot for single-key commands. Multi-key commands carrying their keys in {@code args}
185+
* still require to share the same slot as the {@code key}.
183186
*
184187
* <pre>
185188
* <code>
186189
* // SET foo bar EX 10 NX
187-
* execute("SET", "foo".getBytes(), asBinaryList("bar", "EX", 10, "NX")
190+
* execute("SET", "foo".getBytes(), asBinaryList("bar", "EX", 10, "NX"))
188191
* </code>
189192
* </pre>
190193
*
@@ -860,7 +863,8 @@ static class JedisClusterNodeResourceProvider implements ClusterNodeResourceProv
860863

861864
PropertyAccessor accessor = new DirectFieldAccessFallbackBeanWrapper(cluster);
862865
this.connectionHandler = accessor.isReadableProperty("connectionHandler")
863-
? (JedisClusterConnectionHandler) accessor.getPropertyValue("connectionHandler") : null;
866+
? (JedisClusterConnectionHandler) accessor.getPropertyValue("connectionHandler")
867+
: null;
864868
} else {
865869
this.connectionHandler = null;
866870
}

src/main/java/org/springframework/data/redis/connection/lettuce/LettuceKeyCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public Long touch(byte[]... keys) {
165165
return null;
166166
}
167167
if (isQueueing()) {
168-
transaction(connection.newLettuceTxResult(getConnection().touch(keys)));
168+
transaction(connection.newLettuceResult(getAsyncConnection().touch(keys)));
169169
return null;
170170
}
171171
return getConnection().touch(keys);

src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@
6969
import org.springframework.data.redis.core.StringRedisTemplate;
7070
import org.springframework.data.redis.core.types.Expiration;
7171
import org.springframework.data.redis.core.types.RedisClientInfo;
72-
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
7372
import org.springframework.data.redis.serializer.RedisSerializer;
74-
import org.springframework.data.redis.serializer.StringRedisSerializer;
7573
import org.springframework.data.redis.test.util.RedisClientRule;
7674
import org.springframework.data.redis.test.util.RedisDriver;
7775
import org.springframework.data.redis.test.util.WithRedisDriver;
@@ -2778,11 +2776,10 @@ public void hStrLenReturnsZeroWhenKeyDoesNotExist() {
27782776
@Test // DATAREDIS-694
27792777
public void touchReturnsNrOfKeysTouched() {
27802778

2781-
connection.set("touch.this", "Can't touch this! - oh-oh oh oh oh-oh-oh");
2782-
2779+
actual.add(connection.set("touch.this", "Can't touch this! - oh-oh oh oh oh-oh-oh"));
27832780
actual.add(connection.touch("touch.this", "touch.that"));
27842781

2785-
verifyResults(Arrays.asList(new Object[] { 1L }));
2782+
verifyResults(Arrays.asList(new Object[] { Boolean.TRUE, 1L }));
27862783
}
27872784

27882785
@Test // DATAREDIS-694

0 commit comments

Comments
 (0)