refactoring

pull/3951/head
Nikita Koksharov 3 years ago
parent 6f50e71d03
commit 841c9353ab

@ -1047,6 +1047,11 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
RPromise<Map<K, V>> handleGetAllResult(long startTime, RFuture<Map<K, V>> res) {
RPromise<Map<K, V>> result = new RedissonPromise<>();
res.onComplete((r, ex) -> {
if (ex != null) {
result.tryFailure(ex);
return;
}
Map<K, V> map = r.entrySet().stream()
.filter(e -> e.getValue() != null)
.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue()));
@ -2091,15 +2096,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
RFuture<Map<K, V>> getAndRemoveValues(Collection<K> keys) {
double syncId = ThreadLocalRandom.current().nextDouble();
List<Object> params = new ArrayList<>();
params.add(System.currentTimeMillis());
params.add(syncId);
for (K key : keys) {
params.add(encodeMapKey(key));
}
RFuture<List<Object>> future = getAndRemoveValuesOperation(commandExecutor, null, getRawName(), params);
RFuture<List<Object>> future = getAndRemoveValuesOperation(commandExecutor, null, getRawName(), (Collection<Object>) keys, syncId);
RPromise<Map<K, V>> result = new RedissonPromise<>();
if (atomicExecution) {
@ -2164,7 +2161,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
return result;
}
RFuture<List<Object>> getAndRemoveValuesOperation(CommandAsyncExecutor commandExecutor, MasterSlaveEntry entry, String name, List<Object> params) {
RFuture<List<Object>> getAndRemoveValuesOperation(CommandAsyncExecutor commandExecutor, MasterSlaveEntry entry, String name, Collection<Object> keys, double syncId) {
List<Object> params = new ArrayList<>();
params.add(System.currentTimeMillis());
params.add(syncId);
for (Object key : keys) {
params.add(encodeMapKey(key));
}
String script = "local syncs = 0; "
+ "local values = {}; "
+ "local result = {}; "

Loading…
Cancel
Save