本文整理了Java中io.lettuce.core.KeyValue.getValueOrElse()
方法的一些代码示例,展示了KeyValue.getValueOrElse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.getValueOrElse()
方法的具体详情如下:
包路径:io.lettuce.core.KeyValue
类名称:KeyValue
方法名:getValueOrElse
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Flux<MultiValueResponse<List<ByteBuffer>, ByteBuffer>> mGet(Publisher<List<ByteBuffer>> keyCollections) {
return connection.execute(cmd -> Flux.from(keyCollections).concatMap((keys) -> {
Assert.notNull(keys, "Keys must not be null!");
return cmd.mget(keys.toArray(new ByteBuffer[0])).map((value) -> value.getValueOrElse(EMPTY_BYTE_BUFFER))
.collectList().map((values) -> new MultiValueResponse<>(keys, values));
}));
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Flux<MultiValueResponse<HGetCommand, ByteBuffer>> hMGet(Publisher<HGetCommand> commands) {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getFields(), "Fields must not be null!");
Mono<List<KeyValue<ByteBuffer, ByteBuffer>>> result;
if (command.getFields().size() == 1) {
ByteBuffer key = command.getFields().iterator().next();
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
} else {
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
}
return result.map(value -> new MultiValueResponse<>(command,
value.stream().map(keyValue -> keyValue.getValueOrElse(null)).collect(Collectors.toList())));
}));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Flux<MultiValueResponse<List<ByteBuffer>, ByteBuffer>> mGet(Publisher<List<ByteBuffer>> keyCollections) {
return connection.execute(cmd -> Flux.from(keyCollections).concatMap((keys) -> {
Assert.notNull(keys, "Keys must not be null!");
return cmd.mget(keys.toArray(new ByteBuffer[0])).map((value) -> value.getValueOrElse(EMPTY_BYTE_BUFFER))
.collectList().map((values) -> new MultiValueResponse<>(keys, values));
}));
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Flux<MultiValueResponse<List<ByteBuffer>, ByteBuffer>> mGet(Publisher<List<ByteBuffer>> keyCollections) {
return connection.execute(cmd -> Flux.from(keyCollections).concatMap((keys) -> {
Assert.notNull(keys, "Keys must not be null!");
return cmd.mget(keys.toArray(new ByteBuffer[0])).map((value) -> value.getValueOrElse(EMPTY_BYTE_BUFFER))
.collectList().map((values) -> new MultiValueResponse<>(keys, values));
}));
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Flux<MultiValueResponse<HGetCommand, ByteBuffer>> hMGet(Publisher<HGetCommand> commands) {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getFields(), "Fields must not be null!");
Mono<List<KeyValue<ByteBuffer, ByteBuffer>>> result;
if (command.getFields().size() == 1) {
ByteBuffer key = command.getFields().iterator().next();
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
} else {
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
}
return result.map(value -> new MultiValueResponse<>(command,
value.stream().map(keyValue -> keyValue.getValueOrElse(null)).collect(Collectors.toList())));
}));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Flux<MultiValueResponse<HGetCommand, ByteBuffer>> hMGet(Publisher<HGetCommand> commands) {
return connection.execute(cmd -> Flux.from(commands).concatMap(command -> {
Assert.notNull(command.getKey(), "Key must not be null!");
Assert.notNull(command.getFields(), "Fields must not be null!");
Mono<List<KeyValue<ByteBuffer, ByteBuffer>>> result;
if (command.getFields().size() == 1) {
ByteBuffer key = command.getFields().iterator().next();
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
} else {
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
}
return result.map(value -> new MultiValueResponse<>(command,
value.stream().map(keyValue -> keyValue.getValueOrElse(null)).collect(Collectors.toList())));
}));
}
内容来源于网络,如有侵权,请联系作者删除!