本文整理了Java中io.vertx.redis.RedisClient.hget
方法的一些代码示例,展示了RedisClient.hget
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisClient.hget
方法的具体详情如下:
包路径:io.vertx.redis.RedisClient
类名称:RedisClient
方法名:hget
[英]Get the value of a hash field
[中]获取散列字段的值
代码示例来源: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 value of a hash field
* @param key Key string
* @param field Field name
* @param handler Handler for the result of this call.
* @return
*/
public io.vertx.rxjava.redis.RedisClient hget(String key, String field, Handler<AsyncResult<String>> handler) {
delegate.hget(key, field, handler);
return this;
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Get the value of a hash field
* @param key Key string
* @param field Field name
* @param handler Handler for the result of this call.
* @return
*/
public io.vertx.rxjava.redis.RedisClient hget(String key, String field, Handler<AsyncResult<String>> handler) {
delegate.hget(key, field, handler);
return this;
}
代码示例来源:origin: io.vertx/vertx-service-discovery-backend-redis
@Override
public void getRecord(String uuid, Handler<AsyncResult<Record>> resultHandler) {
redis.hget(key, uuid, ar -> {
if (ar.succeeded()) {
if (ar.result() != null) {
resultHandler.handle(Future.succeededFuture(new Record(new JsonObject(ar.result()))));
} else {
resultHandler.handle(Future.succeededFuture(null));
}
} else {
resultHandler.handle(Future.failedFuture(ar.cause()));
}
});
}
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
public void getRecord(String uuid, Handler<AsyncResult<Record>> resultHandler) {
redis.hget(key, uuid, ar -> {
if (ar.succeeded()) {
if (ar.result() != null) {
resultHandler.handle(Future.succeededFuture(new Record(new JsonObject(ar.result()))));
} else {
resultHandler.handle(Future.succeededFuture(null));
}
} else {
resultHandler.handle(Future.failedFuture(ar.cause()));
}
});
}
}
代码示例来源:origin: io.vertx/vertx-service-discovery-backend-redis
@Override
public void remove(String uuid, Handler<AsyncResult<Record>> resultHandler) {
Objects.requireNonNull(uuid, "No registration id in the record");
redis.hget(key, uuid, ar -> {
if (ar.succeeded()) {
if (ar.result() != null) {
redis.hdel(key, uuid, deletion -> {
if (deletion.succeeded()) {
resultHandler.handle(Future.succeededFuture(
new Record(new JsonObject(ar.result()))));
} else {
resultHandler.handle(Future.failedFuture(deletion.cause()));
}
});
} else {
resultHandler.handle(Future.failedFuture("Record '" + uuid + "' not found"));
}
} else {
resultHandler.handle(Future.failedFuture(ar.cause()));
}
});
}
代码示例来源:origin: vert-x3/vertx-service-discovery
@Override
public void remove(String uuid, Handler<AsyncResult<Record>> resultHandler) {
Objects.requireNonNull(uuid, "No registration id in the record");
redis.hget(key, uuid, ar -> {
if (ar.succeeded()) {
if (ar.result() != null) {
redis.hdel(key, uuid, deletion -> {
if (deletion.succeeded()) {
resultHandler.handle(Future.succeededFuture(
new Record(new JsonObject(ar.result()))));
} else {
resultHandler.handle(Future.failedFuture(deletion.cause()));
}
});
} else {
resultHandler.handle(Future.failedFuture("Record '" + uuid + "' not found"));
}
} else {
resultHandler.handle(Future.failedFuture(ar.cause()));
}
});
}
代码示例来源:origin: org.swisspush.gateleen/gateleen-queue
@Override
public Future<QueueCircuitState> getQueueCircuitState(String circuitHash) {
Future<QueueCircuitState> future = Future.future();
redisClient.hget(buildInfosKey(circuitHash), FIELD_STATE, event -> {
if(event.failed()){
future.fail(event.cause());
} else {
String stateAsString = event.result();
if(StringUtils.isEmpty(stateAsString)){
log.info("No status information found for circuit " + circuitHash + ". Using default value " + QueueCircuitState.CLOSED);
}
future.complete(QueueCircuitState.fromString(stateAsString, QueueCircuitState.CLOSED));
}
});
return future;
}
代码示例来源:origin: org.swisspush.gateleen/gateleen-queue
@Override
public Future<QueueCircuitState> getQueueCircuitState(PatternAndCircuitHash patternAndCircuitHash) {
Future<QueueCircuitState> future = Future.future();
redisClient.hget(buildInfosKey(patternAndCircuitHash.getCircuitHash()), FIELD_STATE, event -> {
if(event.failed()){
future.fail(event.cause());
} else {
String stateAsString = event.result();
if(StringUtils.isEmpty(stateAsString)){
log.info("No status information found for circuit " + patternAndCircuitHash.getPattern().pattern() + ". Using default value " + QueueCircuitState.CLOSED);
}
future.complete(QueueCircuitState.fromString(stateAsString, QueueCircuitState.CLOSED));
}
});
return future;
}
代码示例来源:origin: org.swisspush.gateleen/gateleen-hook
@Override
public Future<JsonObject> getQueueRequest(String queue) {
Future<JsonObject> future = Future.future();
if(StringUtils.isEmpty(queue)){
future.fail("Queue is not allowed to be empty");
return future;
}
redisClient.hget(QUEUE_REQUESTS, queue, reply -> {
if(reply.failed()){
String message = "get queue request '"+queue+"' from hash '" + QUEUE_REQUESTS+ "' resulted in cause " + logCause(reply);
log.error(message);
future.fail(message);
} else {
String resultStr = reply.result();
if(StringUtils.isNotEmpty(resultStr)) {
try {
JsonObject queueRequest = new JsonObject(resultStr);
future.complete(queueRequest);
} catch (DecodeException ex) {
future.fail("Failed to decode queue request for queue '" + queue + "'. Got this from storage: " + resultStr);
}
} else {
future.complete(null);
}
}
});
return future;
}
代码示例来源:origin: sczyh30/vertx-kue
/**
* Get a property of the job from backend.
*
* @param key property key(name)
* @return async result
*/
@Fluent
public Future<String> get(String key) {
Future<String> future = Future.future();
client.hget(RedisHelper.getKey("job:" + this.id), key, future.completer());
return future;
}
代码示例来源:origin: org.swisspush/redisques
break;
case getLock:
redisClient.hget(getLocksKey(), body.getJsonObject(PAYLOAD).getString(QUEUENAME), new GetLockHandler(event));
break;
case deleteLock:
内容来源于网络,如有侵权,请联系作者删除!