Feature Comparison: Redisson vs Lettuce
When it comes to the battle of third-party Redis Java clients, which one reigns supreme: Redisson or Lettuce?
Redisson is a Redis Java client that includes many common implementations of distributed Java collections, objects, and services. As a result, Redisson dramatically lowers the Redis learning curve for Java developers, making it easier than ever to build key-value Redis databases.
Lettuce describes itself as "a scalable Redis client for building non-blocking Reactive applications." The Lettuce project includes both synchronous and asynchronous support for the Redis API, including Java data structures, the publish/subscribe pattern, and high availability and scalability.
Both Redisson and Lettuce are competitive options for using Java with Redis. In this article, we'll discuss exactly how the two alternatives stack up against each other in a Redisson vs. Lettuce feature comparison.
|Map||plain commands only|
|Set||plain commands only|
|List||plain commands only|
|Queue||plain commands only|
|Deque||plain commands only|
|ScoredSortedSet||plain commands only|
|Stream||plain commands only|
When it comes to Java distributed collections, Redisson has a much more ample feature set. Lettuce supports the following collections for plain commands only:
Redisson includes support for all of the above collections, as well as many more:
Distributed locks and synchronizers
Redisson is the clear winner with distributed locks and synchronizers. The Redisson feature set includes:
Lettuce, on the other hand, includes none of these implementations.
|Object holder||plain commands only|
|AtomicLong||plain commands only|
|Publish/Subscribe||plain commands only|
|AtomicDouble||plain commands only|
|Geospatial||plain commands only|
|BitSet||plain commands only|
|HyperLogLog||plain commands only|
Both Redisson and Lettuce have a good selection of Java distributed objects. The Lettuce offerings include:
- Object holder
Note that all of these Lettuce implementations are for plain commands only.
Redisson, meanwhile, includes all of the objects above as well as:
Advanced cache support
|JCache API with near cache
(up to 45x faster)
|Read-through strategy support|
|Write-through strategy support|
|Write-behind strategy support|
Redisson excels when it comes to caching, which can be a massive boost to database performance. The time and effort saved from caching data adds up in the long run, helping your applications run faster and retrieve information more quickly.
The caching features in Redisson include:
- An implementation of the JCache API for Redis, including near caching to execute database operations up to 45 times faster.
- Support for read-through, write-through, and write-behind caching strategies.
Advanced cache support in Lettuce, on the other hand, is scanty in comparison. Lettuce does not include support for caching in JCache or Spring.
Java transactions are a programming paradigm in which multiple commands are all executed as a single step, ensuring that they all either succeed or fail as a single unit. This is crucial for use cases such as financial transactions, in which a single operation (e.g. a money transfer) is actually performed by multiple commands under the hood.
If you need support for Java transactions, you'll have to use Redisson, which comes equipped with an API for that purpose. Lettuce, meanwhile, includes no such feature.
|Reactive stream interface|
Using programming models such as asynchronous, reactive, and RxJava2 is an excellent way to optimize your Java applications. Fortunately, both Redisson and Lettuce include full-fledged support for these three programming frameworks. (Lettuce specifically highlights its use for "building non-blocking Reactive applications.")
What's more, both Redisson and Lettuce have native support for thread-safety for instance variables. This helps reduce the likelihood of errors, crashes, and race conditions during program execution.
Integration with frameworks
|Spring Cache with near cache
(up to 45x faster)
|Hibernate Cache with near cache
(up to 5x faster)
|MyBatis Cache with near cache
(up to 45x faster)
|Tomcat Session Manager|
Custom data serialization
|LZ4 compression codec|
|Snappy compression codec|
Stability and ease of use
|Fully-managed services support
(AWS Elasticache, Azure Cache...)
|Large memory amount handling|
Stability and ease of use are two essential components of any enterprise-grade database. The good news is that both Redisson and Lettuce are capable of handling large amounts of memory.
However, only Redisson includes support for fully managed cloud services, such as Amazon ElastiCache and Azure Cache for Redis. Being able to take advantage of these fully managed services can significantly lower the learning curve for new users. Rather than managing your Redis deployment yourself, using Redisson allows you to pass off this task to the cloud provider, simplifying your IT environment.
Use Redis commands mapping table to find Redisson method for a particular Redis command.