DATAREDIS-694 - Add support for TOUCH.
We now support TOUCH for both Lettuce and Jedis in imperative and reactive (Lettuce only) KeyCommands. Original pull request: #284.
This commit is contained in:
committed by
Mark Paluch
parent
5e77dee4dc
commit
8a640a29b6
@@ -2771,6 +2771,25 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
|
||||
actual.add(connection.hStrLen("hash-no-exist", "key-2"));
|
||||
|
||||
verifyResults(
|
||||
Arrays.asList(new Object[] { 0L }));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-694
|
||||
public void touchReturnsNrOfKeysTouched() {
|
||||
|
||||
connection.set("touch.this", "Can't touch this! - oh-oh oh oh oh-oh-oh");
|
||||
|
||||
actual.add(connection.touch("touch.this", "touch.that"));
|
||||
|
||||
verifyResults(Arrays.asList(new Object[] { 1L }));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-694
|
||||
public void touchReturnsZeroIfNoKeysTouched() {
|
||||
|
||||
actual.add(connection.touch("touch.this", "touch.that"));
|
||||
|
||||
verifyResults(Arrays.asList(new Object[] { 0L }));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,16 @@ import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -375,7 +384,7 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREDIS-689
|
||||
public void executeWithNoKeyAndArgsThrowsException() {
|
||||
clusterConnection.execute("KEYS", null, Collections.singletonList("*".getBytes()));
|
||||
clusterConnection.execute("KEYS", (byte[]) null, Collections.singletonList("*".getBytes()));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-529
|
||||
@@ -2195,4 +2204,19 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(nativeConnection.zrange(SAME_SLOT_KEY_3_BYTES, 0, -1),
|
||||
hasItems(VALUE_1_BYTES, VALUE_2_BYTES, VALUE_3_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-694
|
||||
public void touchReturnsNrOfKeysTouched() {
|
||||
|
||||
nativeConnection.set(KEY_1, VALUE_1);
|
||||
nativeConnection.set(KEY_2, VALUE_1);
|
||||
|
||||
assertThat(clusterConnection.keyCommands().touch(KEY_1_BYTES, KEY_2_BYTES, KEY_3_BYTES), is(2L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-694
|
||||
public void touchReturnsZeroIfNoKeysTouched() {
|
||||
assertThat(clusterConnection.keyCommands().touch(KEY_1_BYTES), is(0L));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -287,4 +287,23 @@ public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTest
|
||||
.verify();
|
||||
assertThat(nativeCommands.exists(KEY_1), is(0L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-694
|
||||
public void touchReturnsNrOfKeysTouched() {
|
||||
|
||||
nativeCommands.set(KEY_1, VALUE_1);
|
||||
nativeCommands.set(KEY_2, VALUE_2);
|
||||
|
||||
StepVerifier.create(connection.keyCommands().touch(Arrays.asList(KEY_1_BBUFFER, KEY_2_BBUFFER, KEY_3_BBUFFER)))
|
||||
.expectNext(2L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-694
|
||||
public void touchReturnsZeroIfNoKeysTouched() {
|
||||
|
||||
StepVerifier.create(connection.keyCommands().touch(Arrays.asList(KEY_1_BBUFFER))) //
|
||||
.expectNext(0L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user