Skip to content

Instantly share code, notes, and snippets.

@brachi-wernick
Created February 24, 2020 21:24
Show Gist options
  • Save brachi-wernick/29831cebb231eca5710c914d3a7d2a6c to your computer and use it in GitHub Desktop.
Save brachi-wernick/29831cebb231eca5710c914d3a7d2a6c to your computer and use it in GitHub Desktop.
api to get data from redis
private void get(RoutingContext routingContext) {
long start = System.nanoTime();
String userId = String.valueOf(new Random().nextInt(1000000));
String redisKey = "{" + userId + "}" + userId;
RFuture<String> async = RedisClient.getRedisClient().<String>getBucket(redisKey).getAsync();
async.onComplete((val, throwable) -> {
long end = System.nanoTime();
double totalMicroTime = (end - start) / 1000000.000;
System.out.println("total get:" + totalMicroTime);
routingContext.response()
.putHeader("content-type", "text/plain")
.end("found" + val);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment