Created
February 24, 2020 21:24
-
-
Save brachi-wernick/29831cebb231eca5710c914d3a7d2a6c to your computer and use it in GitHub Desktop.
api to get data from redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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