Fixed - Spring Data Redis RedissonConnection.del() method doesn't work in pipeline on Redis cluster. #3237

pull/3248/head
Nikita Koksharov 4 years ago
parent 4cdfd46042
commit 683b0dfce2

@ -507,6 +507,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Red
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -506,6 +506,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Red
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -511,6 +511,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Red
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -560,6 +560,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Def
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -560,6 +560,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Def
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -560,6 +560,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Def
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -560,6 +560,14 @@ public class RedissonClusterConnection extends RedissonConnection implements Def
@Override
public Long del(byte[]... keys) {
if (isQueueing() || isPipelined()) {
for (byte[] key: keys) {
write(key, LongCodec.INSTANCE, RedisCommands.DEL, key);
}
return null;
}
RFuture<Long> f = executeAsync(RedisCommands.DEL, keys);
return sync(f);
}

@ -21,10 +21,7 @@ import org.springframework.data.redis.connection.RedisNode.NodeType;
import org.springframework.data.redis.core.types.RedisClientInfo;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import static org.assertj.core.api.Assertions.*;
import static org.redisson.connection.MasterSlaveConnectionManager.MAX_SLOT;
@ -181,6 +178,32 @@ public class RedissonClusterConnectionTest {
assertThat(info.size()).isGreaterThan(10);
}
@Test
public void testDelPipeline() {
byte[] k = "key".getBytes();
byte[] v = "val".getBytes();
connection.set(k, v);
connection.openPipeline();
connection.get(k);
connection.del(k);
List<Object> results = connection.closePipeline();
byte[] val = (byte[])results.get(0);
assertThat(val).isEqualTo(v);
Long res = (Long) results.get(1);
assertThat(res).isEqualTo(1);
}
@Test
public void testDel() {
List<byte[]> keys = new ArrayList<>();
for (int i = 0; i < 10; i++) {
byte[] key = ("test" + i).getBytes();
keys.add(key);
connection.set(key, ("test" + i).getBytes());
}
connection.del(keys.toArray(new byte[0][]));
}
@Test
public void testResetConfigStats() {

Loading…
Cancel
Save