title: Jedis and Lettuce async abilities
body: <p>I am using redis with Akka so I need no blocking calls. Lettuce has async-future call built into it. But Jedis is the recommended client by Redis. Can someone tell me if I am using both of them the right way. If so which one is better.</p>
  
  <p><strong>JEDIS</strong>
  I am using a static Jedis connection pool to get con and using Akka future callback to process the result. My concern here is when I use another thread (callable) to get the result that thread is eventually going to block for the result. While Lettuce might have some more efficient way of doing this.</p>
  
  <pre><code> private final class OnSuccessExtension extends OnSuccess&lt;String&gt; {
              private final ActorRef senderActorRef;
              private final Object message;
              @Override
              public void onSuccess(String valueRedis) throws Throwable {
                  log.info(getContext().dispatcher().toString());
                  senderActorRef.tell((String) message, ActorRef.noSender());
              }
               public OnSuccessExtension(ActorRef senderActorRef,Object message) {
                      this.senderActorRef = senderActorRef;
                      this.message=message;
                  }
          }
          ActorRef senderActorRef = getSender(); //never close over a future
              if (message instanceof String) {
          Future&lt;String&gt; f =akka.dispatch.Futures.future(new Callable&lt;String&gt;() {
                      public String call() {
                          String result;
                          try(Jedis jedis=JedisWrapper.redisPool.getResource()) {
                              result = jedis.get("name");
                          }
                          return result;
                      }
                  }, ex);
                  f.onSuccess(new OnSuccessExtension(senderActorRef,message), ex);
      }
  </code></pre>
  
  <p><strong>LETTUCE</strong></p>
  
  <pre><code>ExecutorService executorService = Executors.newFixedThreadPool(10);
  public void onReceive(Object message) throws Exception {
          ActorRef senderActorRef = getSender(); //never close over a future
          if (message instanceof String) {
  
              final RedisFuture&lt;String&gt; future = lettuce.connection.get("name");
              future.addListener(new Runnable() {
                  final ActorRef sender = senderActorRef;
                  final String msg =(String) message;
                  @Override
                  public void run() {
                      try {
                          String value = future.get();
                          log.info(value);
                          sender.tell(message, ActorRef.noSender());
                      } catch (Exception e) {
                      }
                  }
              }, executorService);
  </code></pre>
  
  <p>If lettuce is a better option for Async calls. Then what type of executor should I go with in production environment. If possible can I use a Akka dispatcher as an execution context for Letture future call.</p>