Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2203

How to pass own executors to the redis lettuce library?

$
0
0

I have below code to get the data from Redis asynchronously. By default get() call in lettuce library uses nio-event thread pool.

Code 1:

StatefulRedisConnection<String, String> connection = redisClient.connect();RedisAsyncCommands<String, String> command = connection.async();CompletionStage<String> result = command.get(id)        .thenAccept(code ->                      logger.log(Level.INFO, "Thread Id "+ Thread.currentThread().getName());                     //Sample code to print thread ID

Thread Id printed is lettuce-nioEventLoop-6-2.

Code 2:

CompletionStage<String> result = command.get(id)            .thenAcceptAsync(code -> {                         logger.log(Level.INFO, "Thread Id "+ Thread.currentThread().getName());              //my original code}, executors);

Thread Id printed is pool-1-thread-1.

My questions:

  1. Is there a way to pass my executors?
  2. Is it recommended approach to use nio-event thread pool to get(using get() call) the data from redis?

Lettuce version: 5.2.2.RELEASE

thanks, Ashok


Viewing all articles
Browse latest Browse all 2203

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>