refactoring

pull/4608/head
Nikita Koksharov 2 years ago
parent c8644061d4
commit a3ede6cb29

@ -115,7 +115,7 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
for (GeoEntry entry : entries) {
params.add(entry.getLongitude());
params.add(entry.getLatitude());
params.add(encode(params, entry.getMember()));
encode(params, entry.getMember());
}
return commandExecutor.writeAsync(getRawName(), StringCodec.INSTANCE, RedisCommands.GEOADD, params.toArray());
}
@ -190,7 +190,7 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
List<Object> params = new ArrayList<>(members.length + 1);
params.add(getRawName());
for (Object member : members) {
params.add(encode(params, member));
encode(params, member);
}
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("GEOHASH",
new MapGetAllDecoder((List<Object>) Arrays.asList(members), 0));
@ -207,7 +207,7 @@ public class RedissonGeo<V> extends RedissonScoredSortedSet<V> implements RGeo<V
List<Object> params = new ArrayList<>(members.length + 1);
params.add(getRawName());
for (Object member : members) {
params.add(encode(params, member));
encode(params, member);
}
MultiDecoder<Map<Object, Object>> decoder = new ListMultiDecoder2(

@ -247,7 +247,7 @@ public abstract class RedissonObject implements RObject {
protected List<ByteBuf> encode(Collection<?> values) {
List<ByteBuf> result = new ArrayList<>(values.size());
for (Object object : values) {
result.add(encode(result, object));
encode(result, object);
}
return result;
}
@ -313,9 +313,10 @@ public abstract class RedissonObject implements RObject {
return commandExecutor.encode(codec, value);
}
public ByteBuf encode(Collection<?> params, Object value) {
public void encode(Collection<?> params, Object value) {
try {
return commandExecutor.encode(codec, value);
Object v = commandExecutor.encode(codec, value);
((Collection<Object>)params).add(v);
} catch (Exception e) {
params.forEach(v -> {
ReferenceCountUtil.safeRelease(v);

@ -57,12 +57,12 @@ public class RedissonQueueSemaphore extends RedissonSemaphore {
params = new ArrayList<>(values.size() + 1);
params.add(values.size());
for (Object value : values) {
params.add(encode(params, value));
encode(params, value);
}
} else {
params = new ArrayList<>(2);
params.add(1);
params.add(encode(params, value));
encode(params, value);
}
return commandExecutor.evalWriteNoRetryAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,
"local value = redis.call('get', KEYS[1]); " +

@ -408,7 +408,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
if (t.getValue() == null) {
throw new NullPointerException("map value can't be null");
}
params.add(encode(params, t.getKey()));
encode(params, t.getKey());
params.add(BigDecimal.valueOf(t.getValue()).toPlainString());
}
@ -525,7 +525,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
params.add(getRawName());
for (Entry<V, Double> entry : objects.entrySet()) {
params.add(BigDecimal.valueOf(entry.getValue()).toPlainString());
params.add(encode(params, entry.getKey()));
encode(params, entry.getKey());
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZADD_INT, params.toArray());
@ -546,7 +546,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
params.add("NX");
for (Entry<V, Double> entry : objects.entrySet()) {
params.add(BigDecimal.valueOf(entry.getValue()).toPlainString());
params.add(encode(params, entry.getKey()));
encode(params, entry.getKey());
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZADD_INT, params.toArray());
@ -568,7 +568,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
params.add("CH");
for (Entry<V, Double> entry : objects.entrySet()) {
params.add(BigDecimal.valueOf(entry.getValue()).toPlainString());
params.add(encode(params, entry.getKey()));
encode(params, entry.getKey());
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZADD_INT, params.toArray());
@ -590,7 +590,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
params.add("CH");
for (Entry<V, Double> entry : objects.entrySet()) {
params.add(BigDecimal.valueOf(entry.getValue()).toPlainString());
params.add(encode(params, entry.getKey()));
encode(params, entry.getKey());
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZADD_INT, params.toArray());
@ -612,7 +612,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
params.add("CH");
for (Entry<V, Double> entry : objects.entrySet()) {
params.add(BigDecimal.valueOf(entry.getValue()).toPlainString());
params.add(encode(params, entry.getKey()));
encode(params, entry.getKey());
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZADD_INT, params.toArray());
@ -949,7 +949,7 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
List<Object> params = new ArrayList<>(c.size() * 2);
for (Object object : c) {
params.add(0);
params.add(encode(params, object));
encode(params, object);
}
return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,

@ -366,7 +366,7 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
List<Object> params = new ArrayList<>(c.size() * 2);
for (Object object : c) {
params.add(score);
params.add(encode(params, object));
encode(params, object);
}
return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_BOOLEAN,

@ -117,7 +117,7 @@ public class RedissonTimeSeries<V> extends RedissonExpirable implements RTimeSer
byte[] random = new byte[16];
ThreadLocalRandom.current().nextBytes(random);
params.add(random);
params.add(encode(params, entry.getValue()));
encode(params, entry.getValue());
}
if (timeToLive > 0) {

Loading…
Cancel
Save