DATAREDIS-1190 - Cluster rename now correctly overwrites existing keys.
rename(…) behavior in cluster-mode is now aligned with standalone Redis behavior that overwrites the target key if it already exists and the renamed key uses a different slot. Previously, the underlying restore command was called without the replace option which caused BUSYKEY failures. Original Pull Request: #555
This commit is contained in:
committed by
Christoph Strobl
parent
25fa3b7267
commit
1709d19523
@@ -269,7 +269,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
if (value != null && value.length > 0) {
|
||||
|
||||
restore(targetKey, 0, value);
|
||||
restore(targetKey, 0, value, true);
|
||||
del(sourceKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class LettuceClusterKeyCommands extends LettuceKeyCommands {
|
||||
|
||||
if (value != null && value.length > 0) {
|
||||
|
||||
restore(targetKey, 0, value);
|
||||
restore(targetKey, 0, value, true);
|
||||
del(sourceKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,6 +413,9 @@ public interface ClusterConnectionTests {
|
||||
// DATAREDIS-315
|
||||
void rename();
|
||||
|
||||
// DATAREDIS-1190
|
||||
void renameShouldOverwriteTargetKey();
|
||||
|
||||
// DATAREDIS-315
|
||||
void renameNXWhenOnSameSlot();
|
||||
|
||||
|
||||
@@ -1412,6 +1412,18 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(nativeConnection.get(KEY_2_BYTES), is(VALUE_1_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1190
|
||||
public void renameShouldOverwriteTargetKey() {
|
||||
|
||||
nativeConnection.set(KEY_1_BYTES, VALUE_1_BYTES);
|
||||
nativeConnection.set(KEY_2_BYTES, VALUE_2_BYTES);
|
||||
|
||||
clusterConnection.rename(KEY_1_BYTES, KEY_2_BYTES);
|
||||
|
||||
assertThat(nativeConnection.exists(KEY_1_BYTES), is(false));
|
||||
assertThat(nativeConnection.get(KEY_2_BYTES), is(VALUE_1_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void renameNXWhenOnSameSlot() {
|
||||
|
||||
|
||||
@@ -1430,6 +1430,18 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(nativeConnection.get(KEY_2), is(VALUE_1));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1190
|
||||
public void renameShouldOverwriteTargetKey() {
|
||||
|
||||
nativeConnection.set(KEY_1, VALUE_1);
|
||||
nativeConnection.set(KEY_2, VALUE_2);
|
||||
|
||||
clusterConnection.rename(KEY_1_BYTES, KEY_2_BYTES);
|
||||
|
||||
assertThat(nativeConnection.exists(KEY_1), is(0L));
|
||||
assertThat(nativeConnection.get(KEY_2), is(VALUE_1));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void renameNXWhenOnSameSlot() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user