io.vertx.redis.RedisClient.hmget()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(240)

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

RedisClient.hmget介绍

[英]Get the values of all the given hash fields
[中]获取所有给定散列字段的值

代码示例

代码示例来源:origin: xenv/gushici

private void getHistoryFromRedis(Message<JsonObject> message) {
  Future<String> total = Future.future(f -> redisClient.hget(Key.REDIS_CLICKS_TOTAL_HASH, "total", f));
  // 7天的历史点击量
  LocalDate localDate = LocalDate.now();
  List<String> keys = new ArrayList<>();
  for (int i = 0; i < 7; i++) {
    keys.add(localDate.toString());
    localDate = localDate.minusDays(1);
  }
  Future<JsonArray> history = Future.future(f -> redisClient.hmget(Key.REDIS_CLICKS_HISTORY_HASH, keys, f));
  CompositeFuture.all(Arrays.asList(total, history)).setHandler(v -> {
    if (v.succeeded()) {
      JsonObject result = new JsonObject();
      result.put("总点击量", total.result());
      result.put("最近七天点击量", history.result());
      message.reply(result);
    } else {
      log.error(v.cause());
      message.fail(500, v.cause().getMessage());
    }
  });
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Get the values of all the given hash fields
 * @param key Key string
 * @param fields Field names
 * @param handler Handler for the result of this call.
 * @return 
 */
public io.vertx.rxjava.redis.RedisClient hmget(String key, List<String> fields, Handler<AsyncResult<JsonArray>> handler) { 
 delegate.hmget(key, fields, handler);
 return this;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Get the values of all the given hash fields
 * @param key Key string
 * @param fields Field names
 * @param handler Handler for the result of this call.
 * @return 
 */
public io.vertx.rxjava.redis.RedisClient hmget(String key, List<String> fields, Handler<AsyncResult<JsonArray>> handler) { 
 delegate.hmget(key, fields, handler);
 return this;
}

代码示例来源:origin: io.vertx/vertx-lang-groovy

public static io.vertx.redis.RedisClient hmget(io.vertx.redis.RedisClient j_receiver, java.lang.String key, java.util.List<java.lang.String> fields, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<Object>>> handler) {
 io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.hmget(key,
  fields != null ? fields.stream().map(elt -> elt).collect(java.util.stream.Collectors.toList()) : null,
  handler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.json.JsonArray>>() {
  public void handle(io.vertx.core.AsyncResult<io.vertx.core.json.JsonArray> ar) {
   handler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromJsonArray(event)));
  }
 } : null));
 return j_receiver;
}
public static io.vertx.redis.RedisClient hmset(io.vertx.redis.RedisClient j_receiver, java.lang.String key, java.util.Map<String, Object> values, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> handler) {

代码示例来源:origin: org.swisspush.gateleen/gateleen-queue

@Override
public Future<JsonObject> getQueueCircuitInformation(String circuitHash) {
  Future<JsonObject> future = Future.future();
  List<String> fields = Arrays.asList(FIELD_STATE, FIELD_FAILRATIO, FIELD_CIRCUIT);
  redisClient.hmget(buildInfosKey(circuitHash), fields, event -> {
    if(event.failed()){
      future.fail(event.cause());
    } else {
      try {
        QueueCircuitState state = QueueCircuitState.fromString(event.result().getString(0), QueueCircuitState.CLOSED);
        String failRatioStr = event.result().getString(1);
        String circuit = event.result().getString(2);
        JsonObject result = new JsonObject();
        result.put("status", state.name().toLowerCase());
        JsonObject info = new JsonObject();
        if (failRatioStr != null) {
          info.put(FIELD_FAILRATIO, Integer.valueOf(failRatioStr));
        }
        if (circuit != null) {
          info.put(FIELD_CIRCUIT, circuit);
        }
        result.put("info", info);
        future.complete(result);
      }catch (Exception e){
        future.fail(e);
      }
    }
  });
  return future;
}

相关文章

RedisClient类方法