DATAREDIS-693 - Add support for UNLINK.
We now support UNLINK for both Jedis & Lettuce throughout the single node and cluster connection. Reactive support is only available for Lettuce. Original pull request: #294.
This commit is contained in:
committed by
Mark Paluch
parent
3ec25eebb8
commit
c11b8d89ea
@@ -2790,6 +2790,26 @@ public abstract class AbstractConnectionIntegrationTests {
|
||||
verifyResults(Arrays.asList(new Object[] { 0L }));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
@IfProfileValue(name = "redisVersion", value = "4.0+")
|
||||
public void unlinkReturnsNrOfKeysRemoved() {
|
||||
|
||||
connection.set("unlink.this", "Can't track this!");
|
||||
|
||||
actual.add(connection.unlink("unlink.this", "unlink.that"));
|
||||
|
||||
verifyResults(Arrays.asList(new Object[] { 1L }));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
@IfProfileValue(name = "redisVersion", value = "4.0+")
|
||||
public void unlinkReturnsZeroIfNoKeysRemoved() {
|
||||
|
||||
actual.add(connection.unlink("unlink.this"));
|
||||
|
||||
verifyResults(Arrays.asList(new Object[] { 0L }));
|
||||
}
|
||||
|
||||
protected void verifyResults(List<Object> expected) {
|
||||
assertEquals(expected, getResults());
|
||||
}
|
||||
|
||||
@@ -2219,4 +2219,18 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(clusterConnection.keyCommands().touch(KEY_1_BYTES), is(0L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
public void unlinkReturnsNrOfKeysTouched() {
|
||||
|
||||
nativeConnection.set(KEY_1, VALUE_1);
|
||||
nativeConnection.set(KEY_2, VALUE_1);
|
||||
|
||||
assertThat(clusterConnection.keyCommands().unlink(KEY_1_BYTES, KEY_2_BYTES, KEY_3_BYTES), is(2L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
public void unlinkReturnsZeroIfNoKeysTouched() {
|
||||
assertThat(clusterConnection.keyCommands().unlink(KEY_1_BYTES), is(0L));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2182,4 +2182,32 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
assertThat(nativeConnection.zrange(SAME_SLOT_KEY_3, 0, -1), hasItems(VALUE_1, VALUE_2, VALUE_3));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
public void unlinkReturnsNrOfKeysTouched() {
|
||||
|
||||
nativeConnection.set(KEY_1, VALUE_1);
|
||||
nativeConnection.set(KEY_2, VALUE_1);
|
||||
|
||||
assertThat(clusterConnection.keyCommands().unlink(KEY_1_BYTES, KEY_2_BYTES, KEY_3_BYTES), is(2L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
public void unlinkReturnsZeroIfNoKeysTouched() {
|
||||
assertThat(clusterConnection.keyCommands().unlink(KEY_1_BYTES), is(0L));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,14 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.RedisSystemException;
|
||||
import org.springframework.data.redis.connection.DataType;
|
||||
import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyCommand;
|
||||
import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse;
|
||||
import org.springframework.data.redis.test.util.MinimumRedisVersionRule;
|
||||
import org.springframework.test.annotation.IfProfileValue;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link LettuceReactiveKeyCommands}.
|
||||
@@ -43,6 +46,8 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.Numeric
|
||||
*/
|
||||
public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTestsBase {
|
||||
|
||||
public @Rule MinimumRedisVersionRule versionRule = new MinimumRedisVersionRule();
|
||||
|
||||
@Test // DATAREDIS-525
|
||||
public void existsShouldReturnTrueForExistingKeys() {
|
||||
|
||||
@@ -306,4 +311,26 @@ public class LettuceReactiveKeyCommandsTests extends LettuceReactiveCommandsTest
|
||||
.expectNext(0L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
@IfProfileValue(name = "redisVersion", value = "4.0.0+")
|
||||
public void unlinkReturnsNrOfKeysRemoved() {
|
||||
|
||||
nativeCommands.set(KEY_1, VALUE_1);
|
||||
nativeCommands.set(KEY_2, VALUE_2);
|
||||
|
||||
StepVerifier.create(connection.keyCommands().unlink(Arrays.asList(KEY_1_BBUFFER, KEY_2_BBUFFER, KEY_3_BBUFFER)))
|
||||
.expectNext(2L) //
|
||||
.verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-693
|
||||
@IfProfileValue(name = "redisVersion", value = "4.0.0+")
|
||||
public void unlinkReturnsZeroIfNoKeysRemoved() {
|
||||
|
||||
StepVerifier.create(connection.keyCommands().unlink(Arrays.asList(KEY_1_BBUFFER))) //
|
||||
.expectNext(0L) //
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user