Does Jedis support asynchronous operations

I am using Jedis (java client) to communicate with a Redis server. I have three Redis instances running on three different nodes. I want to “get” (read) some records from 3 Redis instances. I want to release these "gets" (reading) in parallel, and then do some processing of the received data and form the final output.

What is the best way to do this in java?

One way is to create 3 threads and isssue "get" (read) in each of them (synchronously). Wait until all 3 teams are complete, and then combine the result.

Does Jedis have a mechanism for issuing 3 “receive” (any command for this) asynchronously with the callback function?


I have 3 different instances of Redis. So, you suggest using "ShardedJedisPipeline" (jedis / tests / ShardedJedisPipelineTest.java) to interact with these Redis instances in parallel?

The regular Jedis Pipeline (jedis / tests / PipeliningTest.java) simply sends several commands to one Redis instance, so they are executed one after the other on the Redis server (and all answers are available at the end).

Therefore, I assume that I need to use "ShardedJedisPipeline". But there are two limitations to this: 1. I want to execute a Lua script ie "Eval" in 3 Redis instances in parallel. 2. I do not want sharding (some hashing algorithm used by Jedis) to distribute data or read data from instances independently (using its algorithm). We have another data dissemination strategy. Therefore, I want to be able to specify whether the record should be stored in the redis instance and, accordingly, where it should be read from. keyTags seems to provide this mechanism, but is not sure how to use it with "eval".

+5
source share
3 answers

, . AsyncJedis - , Jedis. netty vert.x

+2

ExecutorService Jedis, .

0

As of February 2015, Jedis does not seem to support Async working on a single instance of redis, as you need: https://github.com/xetorthio/jedis/issues/241

What would I do in your case, continue with 3 threads and continue working with Futures and Executor Service, as suggested by @Xorlev above.

0
source

All Articles