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.
Distributed collections
Redisson | Lettuce | |
---|---|---|
Map | plain commands only | |
JSON store | ||
Multimap | ||
Set | plain commands only | |
List | plain commands only | |
Queue | plain commands only | |
Deque | plain commands only | |
SortedSet | ||
ScoredSortedSet | plain commands only | |
PriorityQueue | ||
PriorityDeque | ||
DelayedQueue | ||
Stream | plain commands only | |
RingBuffer | ||
TransferQueue | ||
TimeSeries |
When it comes to Java distributed collections, Redisson has a much more ample feature set. Lettuce supports the following collections for plain commands only:
- Map
- Set
- List
- Queue
- Deque
- ScoredSortedSet
- Stream
Redisson includes support for all of the above collections, as well as many more:
- JSON Store
- Multimap
- SortedSet
- PriorityQueue
- PriorityDeque
- DelayedQueue
- RingBuffer
- TransferQueue
Distributed locks and synchronizers
Redisson | Lettuce | |
---|---|---|
Lock | ||
Semaphore | ||
CountDownLatch | ||
FairLock | ||
Fenced Lock | ||
Spin Lock | ||
MultiLock | ||
ReadWriteLock |
Redisson is the clear winner with distributed locks and synchronizers. The Redisson feature set includes:
- Lock
- Semaphore
- CountDownLatch
- FairLock
- Fenced Lock
- Spin Lock
- MultiLock
- ReadWriteLock
Lettuce, on the other hand, includes none of these implementations.
Distributed objects
Redisson | Lettuce | |
---|---|---|
Object holder | plain commands only | |
JSON holder | ||
AtomicLong | plain commands only | |
LongAdder | ||
DoubleAdder | ||
Publish/Subscribe | plain commands only | |
Reliable Publish/Subscribe | ||
Id Generator | ||
AtomicDouble | plain commands only | |
Geospatial | plain commands only | |
BitSet | plain commands only | |
BloomFilter | ||
BinaryStream | ||
HyperLogLog | plain commands only | |
RateLimiter |
Both Redisson and Lettuce have a good selection of Java distributed objects. The Lettuce offerings include:
- Object holder
- AtomicLong
- Publish/Subscribe
- AtomicDouble
- Geospatial
- BitSet
- HyperLogLog
Note that all of these Lettuce implementations are for plain commands only.
Redisson, meanwhile, includes all of the objects above as well as:
- JSON holder
- LongAdder
- DoubleAdder
- BinaryStream
- RateLimiter
Advanced cache support
Redisson | Lettuce | |
---|---|---|
JCache API | ||
JCache API with near cache (up to 45x faster) |
||
Near Cache | ||
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.
Transactions
Redisson | Lettuce | |
---|---|---|
Transactions API |
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.
API architecture
Redisson | Lettuce | |
---|---|---|
Instance thread-safety | ||
Asynchronous interface | ||
Reactive stream interface | ||
RxJava3 interface |
Using programming models such as asynchronous, reactive, and RxJava3 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.
Distributed services
Redisson | Lettuce | |
---|---|---|
ExecutorService | ||
MapReduce | ||
SchedulerService | ||
RemoteService | ||
LiveObjectService | ||
RediSearch |
Integration with frameworks
Redisson | Lettuce | |
---|---|---|
Spring Boot | ||
Spring Data | ||
Spring Session | ||
Spring Cache | ||
Spring Cache with near cache (up to 45x faster) |
||
Hibernate Cache | ||
Hibernate Cache with near cache (up to 5x faster) |
||
MyBatis Cache | ||
MyBatis Cache with near cache (up to 45x faster) |
||
Quarkus Cache | ||
Quarkus Cache with near cache (up to 45x faster) |
||
Micronaut Cache | ||
Micronaut Cache with near cache (up to 45x faster) |
||
Micronaut Session | ||
Tomcat Session Manager |
Security
Redisson | Lettuce | |
---|---|---|
Authentication | ||
SSL support |
Custom data serialization
Redisson | Lettuce | |
---|---|---|
JSON codec | ||
JDK Serialization | ||
Avro codec | ||
Smile codec | ||
CBOR codec | ||
MsgPack codec | ||
Kryo codec | ||
LZ4 compression codec | ||
Snappy compression codec | ||
Zstd compression codec |
Stability and ease of use
Redisson | Lettuce | |
---|---|---|
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.