fix: fix bug for mset cross slot (miss values except cluster mode)

Signed-off-by: xujie <mikawudi@qq.com>
pull/3818/head
xujie 3 years ago
parent cb162a9b25
commit eedd7b0f15

@ -150,7 +150,7 @@ public class RedissonBuckets implements RBuckets {
} }
return params.toArray(); return params.toArray();
} }
}, buckets.keySet().toArray(new String[]{})); }, buckets.keySet().toArray(new String[]{}), buckets);
} }
} }

@ -28,6 +28,7 @@ import org.redisson.liveobject.core.RedissonObjectBuilder;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@ -118,4 +119,6 @@ public interface CommandAsyncExecutor {
<T, R> RFuture<R> writeBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys); <T, R> RFuture<R> writeBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys);
<T, R> RFuture<R> writeBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String[] keys, Map<String, ?> valueMap);
} }

@ -588,20 +588,35 @@ public class CommandAsyncService implements CommandAsyncExecutor {
@Override @Override
public <T, R> RFuture<R> readBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys) { public <T, R> RFuture<R> readBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys) {
return executeBatchedAsync(true, codec, command, callback, keys); return executeBatchedAsync(true, codec, command, callback, keys, null);
} }
@Override @Override
public <T, R> RFuture<R> writeBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys) { public <T, R> RFuture<R> writeBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys) {
return executeBatchedAsync(false, codec, command, callback, keys); return executeBatchedAsync(false, codec, command, callback, keys, null);
} }
private <T, R> RFuture<R> executeBatchedAsync(boolean readOnly, Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String... keys) { @Override
public <T, R> RFuture<R> writeBatchedAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String[] keys, Map<String, ?> valueMap) {
return executeBatchedAsync(false, codec, command, callback, keys, valueMap);
}
private <T, R> RFuture<R> executeBatchedAsync(boolean readOnly, Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, String[] keys, Map<String, ?> valueMap) {
if (!connectionManager.isClusterMode()) { if (!connectionManager.isClusterMode()) {
List<Object> params = null;
if (valueMap != null) {
params = new ArrayList<>(keys.length * 2);
for (String key : keys) {
params.add(key);
params.add(valueMap.get(key));
}
} else {
params = Arrays.asList(keys);
}
if (readOnly) { if (readOnly) {
return readAsync((String) null, codec, command, keys); return readAsync((String) null, codec, command, params.toArray());
} }
return writeAsync((String) null, codec, command, keys); return writeAsync((String) null, codec, command, params.toArray());
} }
Map<MasterSlaveEntry, Map<Integer, List<String>>> entry2keys = Arrays.stream(keys).collect( Map<MasterSlaveEntry, Map<Integer, List<String>>> entry2keys = Arrays.stream(keys).collect(

Loading…
Cancel
Save