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

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

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

RedisClient.set介绍

[英]Set the string value of a key
[中]设置键的字符串值

代码示例

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

@Override
 public void start() throws Exception {
  // If a config file is set, read the host and port.
  String host = Vertx.currentContext().config().getString("host");
  if (host == null) {
   host = "127.0.0.1";
  }

  // Create the redis client
  final RedisClient client = RedisClient.create(vertx,
    new RedisOptions().setHost(host));

  client.set("key", "value", r -> {
   if (r.succeeded()) {
    System.out.println("key stored");
    client.get("key", s -> {
     System.out.println("Retrieved value: " + s.result());
    });
   } else {
    System.out.println("Connection or Operation Failed " + r.cause());
   }
  });
 }
}

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

/**
 * Set the string value of a key
 * @param key Key of which value to set
 * @param value New value for the key
 * @param handler Handler for the result of this call.
 * @return 
 */
public io.vertx.rxjava.redis.RedisClient set(String key, String value, Handler<AsyncResult<Void>> handler) { 
 delegate.set(key, value, handler);
 return this;
}

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

/**
 * Set the string value of a key
 * @param key Key of which value to set
 * @param value New value for the key
 * @param handler Handler for the result of this call.
 * @return 
 */
public io.vertx.rxjava.redis.RedisClient set(String key, String value, Handler<AsyncResult<Void>> handler) { 
 delegate.set(key, value, handler);
 return this;
}

代码示例来源:origin: sczyh30/vertx-blueprint-microservice

@Override
 public void reset(String key, Handler<AsyncResult<Void>> resultHandler) {
  client.set(COUNTER_PREFIX + key, "0", ar -> {
   if (ar.succeeded()) {
    resultHandler.handle(Future.succeededFuture());
   } else {
    resultHandler.handle(Future.failedFuture(ar.cause()));
   }
  });
 }
}

相关文章

微信公众号

最新文章

更多

RedisClient类方法