Redis client for Java: Jedis, Lettuce and Redisson — overview and examples

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

Redis client for Java: overview of popular libraries



Redis is a high-performance key-value data store, widely used for caching, sessions, queues, and real-time analytics. There are several mature client libraries for working with Redis from Java. In this article, we will look at three of the most popular ones: Jedis, Lettuce and Redisson. Each of them has its own features, advantages, and use cases.



1. Jedis — simple and lightweight client



Jedis is a minimalist synchronous client for Redis. It is easy to learn and well-suited for small projects and microservices where asynchronicity is not required.



Features of Jedis:

  • Synchronous API (blocking calls).
  • Connection pool support (JedisPool).
  • Full support for Redis commands.
  • Does not support asynchronous or reactive operations.


Example of connection and basic operations:

import redis.clients.jedis.Jedis;import redis.clients.jedis.JedisPool;

public class JedisExample { public static void main(String[] args) { // Create a connection pool try (JedisPool pool = new JedisPool("localhost", 6379); Jedis jedis = pool.getResource()) {

// Set and get a value jedis.set("user:100", "Alice"); String value = jedis.get("user:100"); System.out.println("Value: " + value); // Output: Alice

// Working with lists jedis.lpush("queue", "task1"); jedis.lpush("queue", "task2"); String task = jedis.rpop("queue"); System.out.println("Task from queue: " + task); // Output: task1 } }}


When to choose Jedis:

  • Simple project without reactive requirements.
  • Need a minimal dependency (single jar).
  • Classic blocking operations.


2. Lettuce — asynchronous and reactive client



Lettuce is a modern client built on Netty. It supports synchronous, asynchronous, and reactive (Reactive Streams) APIs. It is an excellent choice for high-load systems.



Features of Lettuce:

  • Asynchronous and reactive API (based on Project Reactor).
  • Support for Redis clusters, Sentinel, SSL.
  • Non-blocking operations — high throughput.
  • Support for Redis Pub/Sub, Streams, Transactions.


Example of asynchronous usage:

import io.lettuce.core.RedisClient;import io.lettuce.core.api.StatefulRedisConnection;import io.lettuce.core.api.async.RedisAsyncCommands;

public class LettuceAsyncExample { public static void main(String[] args) { RedisClient client = RedisClient.create("redis://localhost:6379"); try (StatefulRedisConnection<String, String> connection = client.connect()) { RedisAsyncCommands<String, String> async = connection.async();

// Asynchronous set async.set("key:1", "Hello, Lettuce!");

// Asynchronous get with callback async.get("key:1").thenAccept(value -> System.out.println("Received: " + value) );

// Small delay to complete the asynchronous operation try { Thread.sleep(100); } catch (InterruptedException e) { } } client.shutdown(); }}


When to choose Lettuce:

  • High-load systems with a large number of requests.
  • Need for asynchronicity or reactive programming.
  • Working with Redis cluster or Sentinel.


3. Redisson — client with advanced features



Redisson is not just a client, but a full-fledged framework

Recommendations