refactoring

pull/3245/merge
Nikita Koksharov 4 years ago
parent 5338811437
commit 17d51c7adb

@ -49,7 +49,7 @@ public class RedissonLocalCachedMap<K, V> extends RedissonMap<K, V> implements R
public static final String DISABLED_ACK_SUFFIX = ":topic"; public static final String DISABLED_ACK_SUFFIX = ":topic";
private static final RedisCommand<Set<Object>> ALL_KEYS = new RedisCommand<Set<Object>>("EVAL", new MapKeyDecoder(new ObjectSetReplayDecoder<Object>())); private static final RedisCommand<Set<Object>> ALL_KEYS = new RedisCommand<Set<Object>>("EVAL", new MapKeyDecoder(new ObjectSetReplayDecoder<Object>()));
private static final RedisCommand<Set<Entry<Object, Object>>> ALL_ENTRIES = new RedisCommand<Set<Entry<Object, Object>>>("EVAL", new MapEntriesDecoder(new ObjectMapEntryReplayDecoder())); private static final RedisCommand<Set<Entry<Object, Object>>> ALL_ENTRIES = new RedisCommand<>("EVAL", new ObjectMapEntryReplayDecoder());
private static final RedisCommand<Map<Object, Object>> ALL_MAP = new RedisCommand<Map<Object, Object>>("EVAL", new ObjectMapReplayDecoder()); private static final RedisCommand<Map<Object, Object>> ALL_MAP = new RedisCommand<Map<Object, Object>>("EVAL", new ObjectMapReplayDecoder());
private long cacheUpdateLogTime = TimeUnit.MINUTES.toMillis(10); private long cacheUpdateLogTime = TimeUnit.MINUTES.toMillis(10);

@ -1395,7 +1395,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
private static final RedisCommand<MapCacheScanResult<Object, Object>> SCAN = new RedisCommand<MapCacheScanResult<Object, Object>>("EVAL", private static final RedisCommand<MapCacheScanResult<Object, Object>> SCAN = new RedisCommand<MapCacheScanResult<Object, Object>>("EVAL",
new ListMultiDecoder2( new ListMultiDecoder2(
new MapCacheScanResultReplayDecoder(), new MapCacheScanResultReplayDecoder(),
new MapEntriesDecoder(new ObjectMapDecoder(true)))); new ObjectMapDecoder(true)));
@Override @Override
public RFuture<MapScanResult<Object, Object>> scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count) { public RFuture<MapScanResult<Object, Object>> scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count) {

@ -1105,13 +1105,6 @@ public class RedissonStream<K, V> extends RedissonExpirable implements RStream<K
return get(getInfoAsync()); return get(getInfoAsync());
} }
private static final RedisCommand<StreamInfo<Object, Object>> XINFO_STREAM = new RedisCommand<>("XINFO", "STREAM",
new ListMultiDecoder2(
new StreamInfoDecoder(),
new CodecDecoder(),
new ObjectMapDecoder(false)));
@Override @Override
public RFuture<StreamInfo<K, V>> getInfoAsync() { public RFuture<StreamInfo<K, V>> getInfoAsync() {
RedisCommand<StreamInfo<Object, Object>> xinfoStream = new RedisCommand<>("XINFO", "STREAM", RedisCommand<StreamInfo<Object, Object>> xinfoStream = new RedisCommand<>("XINFO", "STREAM",

@ -238,7 +238,7 @@ public interface RedisCommands {
RedisCommand<Object> EVAL_OBJECT = new RedisCommand<Object>("EVAL"); RedisCommand<Object> EVAL_OBJECT = new RedisCommand<Object>("EVAL");
RedisCommand<Object> EVAL_MAP_VALUE = new RedisCommand<Object>("EVAL", new MapValueDecoder()); RedisCommand<Object> EVAL_MAP_VALUE = new RedisCommand<Object>("EVAL", new MapValueDecoder());
RedisCommand<Set<Entry<Object, Object>>> EVAL_MAP_ENTRY = new RedisCommand<Set<Entry<Object, Object>>>("EVAL", RedisCommand<Set<Entry<Object, Object>>> EVAL_MAP_ENTRY = new RedisCommand<Set<Entry<Object, Object>>>("EVAL",
new MapEntriesDecoder(new ObjectMapEntryReplayDecoder())); new ObjectMapEntryReplayDecoder());
RedisCommand<Map<Object, Object>> EVAL_MAP = new RedisCommand<Map<Object, Object>>("EVAL", RedisCommand<Map<Object, Object>> EVAL_MAP = new RedisCommand<Map<Object, Object>>("EVAL",
new ObjectMapReplayDecoder()); new ObjectMapReplayDecoder());
RedisCommand<List<Object>> EVAL_MAP_VALUE_LIST = new RedisCommand<List<Object>>("EVAL", RedisCommand<List<Object>> EVAL_MAP_VALUE_LIST = new RedisCommand<List<Object>>("EVAL",
@ -288,7 +288,7 @@ public interface RedisCommands {
RedisCommand<Map<Object, Object>> HGETALL = new RedisCommand<Map<Object, Object>>("HGETALL", RedisCommand<Map<Object, Object>> HGETALL = new RedisCommand<Map<Object, Object>>("HGETALL",
new ObjectMapReplayDecoder()); new ObjectMapReplayDecoder());
RedisCommand<Set<Entry<Object, Object>>> HGETALL_ENTRY = new RedisCommand<Set<Entry<Object, Object>>>("HGETALL", RedisCommand<Set<Entry<Object, Object>>> HGETALL_ENTRY = new RedisCommand<Set<Entry<Object, Object>>>("HGETALL",
new MapEntriesDecoder(new ObjectMapEntryReplayDecoder())); new ObjectMapEntryReplayDecoder());
RedisCommand<List<Object>> HVALS = new RedisCommand<List<Object>>("HVALS", RedisCommand<List<Object>> HVALS = new RedisCommand<List<Object>>("HVALS",
new MapValueDecoder(new ObjectListReplayDecoder<>())); new MapValueDecoder(new ObjectListReplayDecoder<>()));
RedisCommand<Boolean> HEXISTS = new RedisCommand<Boolean>("HEXISTS", new BooleanReplayConvertor()); RedisCommand<Boolean> HEXISTS = new RedisCommand<Boolean>("HEXISTS", new BooleanReplayConvertor());

@ -15,7 +15,9 @@
*/ */
package org.redisson.client.protocol.decoder; package org.redisson.client.protocol.decoder;
import org.redisson.client.codec.Codec;
import org.redisson.client.handler.State; import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -30,6 +32,14 @@ import java.util.Set;
*/ */
public class ObjectMapEntryReplayDecoder implements MultiDecoder<Set<Entry<Object, Object>>> { public class ObjectMapEntryReplayDecoder implements MultiDecoder<Set<Entry<Object, Object>>> {
@Override
public Decoder<Object> getDecoder(Codec codec, int paramNum, State state) {
if (paramNum % 2 != 0) {
return codec.getMapValueDecoder();
}
return codec.getMapKeyDecoder();
}
@Override @Override
public Set<Entry<Object, Object>> decode(List<Object> parts, State state) { public Set<Entry<Object, Object>> decode(List<Object> parts, State state) {
Map<Object, Object> result = new LinkedHashMap<Object, Object>(parts.size()/2); Map<Object, Object> result = new LinkedHashMap<Object, Object>(parts.size()/2);

Loading…
Cancel
Save