vertx redis

76 views
Skip to first unread message

a.ogny...@gmail.com

unread,
Sep 29, 2017, 7:35:23 AM9/29/17
to vert.x
Hi, according to your documentation, it always uses pipeline mode. But how can i combine or chain multiple requests, for example, execute hgetall multiple times 2 < N < 10 with one ResultHandler ?

Paulo Lopes

unread,
Sep 29, 2017, 6:31:43 PM9/29/17
to vert.x
Redis client will only have 1 connection to redis and will always use pipeline, to get say 10 results of hgetall for example you can write a for loop and collect the data, the request will be send to the server and not queue for each response.

you can see it as follows

for (i = 0, i< 10; i++) {
  redis.hgetall('k' + i, ...)
}

and what is ahppening on the socket is something like

hgetall k0
hgetall k1
...
hgetall k9

<redis is handling the requests>

response for hgetall k0 returns
response for hgetall k1 returns
...
response for hgetall k9 returns

However if redis is fast you might see these returns interleave with the requests but this is fine since it means that both vertx and redis are maximizing the CPU usage and non blocking.

a.ogny...@gmail.com

unread,
Oct 17, 2017, 2:34:45 AM10/17/17
to vert.x
Thank you for your reply! My problem was to caught last handled response and combine them all to a single object (for example, web client).

Paulo Lopes

unread,
Oct 17, 2017, 5:04:29 AM10/17/17
to vert.x
So in your case i think you should investigate the rx (reactve extensions) where you could execute your requests as a stream and then flat map or using any other combine operation to get all results at once.

a.ogny...@gmail.com

unread,
Oct 18, 2017, 12:52:00 AM10/18/17
to vert.x
Ok, I see. I expected you show me some magic with CompleteFuture =))

a.ogny...@gmail.com

unread,
Oct 18, 2017, 12:53:08 AM10/18/17
to vert.x
CompositeFuture*
Reply all
Reply to author
Forward
0 new messages