use of org.redisson.connection.decoder.BucketsDecoder in project redisson by redisson.
the class RedissonBuckets method getAsync.
@Override
public <V> RFuture<Map<String, V>> getAsync(String... keys) {
if (keys.length == 0) {
return RedissonPromise.newSucceededFuture(Collections.emptyMap());
}
Codec commandCodec = new CompositeCodec(StringCodec.INSTANCE, codec, codec);
RedisCommand<Map<Object, Object>> command = new RedisCommand<Map<Object, Object>>("MGET", new MapGetAllDecoder(Arrays.<Object>asList(keys), 0));
return commandExecutor.readBatchedAsync(commandCodec, command, new SlotCallback<Map<Object, Object>, Map<String, V>>() {
final Map<String, V> results = new ConcurrentHashMap<>();
@Override
public void onSlotResult(Map<Object, Object> result) {
for (Map.Entry<Object, Object> entry : result.entrySet()) {
if (entry.getKey() != null && entry.getValue() != null) {
results.put((String) entry.getKey(), (V) entry.getValue());
}
}
}
@Override
public Map<String, V> onFinish() {
return results;
}
@Override
public RedisCommand<Map<Object, Object>> createCommand(List<String> keys) {
return new RedisCommand<>("MGET", new BucketsDecoder(keys));
}
}, keys);
}
Aggregations