io.lettuce.core.KeyValue.getValueOrElse()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中io.lettuce.core.KeyValue.getValueOrElse()方法的一些代码示例,展示了KeyValue.getValueOrElse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.getValueOrElse()方法的具体详情如下:
包路径:io.lettuce.core.KeyValue
类名称:KeyValue
方法名:getValueOrElse

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())));
  }));
}

相关文章

微信公众号

最新文章

更多