Lettuce Replacement:
Why Redisson is the Best Lettuce Alternative

There's no shortage of third-party Java clients for Redis, including Lettuce and Redisson. But which one is the best Redis Java client for your purposes?

Lettuce calls itself "a scalable Redis client for building non-blocking reactive applications." The distinguishing features of Lettuce include synchronous and asynchronous support for Redis via the Java 8 CompletionStage interface; various Java data structures; the publish/subscribe pattern; and scalability and fault-tolerance.

Redisson is a popular third-party Redis Java client. The Redisson project implements many familiar Java objects, collections, and services, which decreases the Redis learning curve for Java developers. In addition, Redisson offers support for important database features such as caching, task scheduling, web sessions, messaging, and microservices.

Both Redisson and Lettuce are good options for Redis Java libraries, so the right choice depends on your unique situation. Looking for the best replacement for Lettuce? In this article, we'll go over why Redisson is the #1 alternative to Lettuce you should consider.

Lettuce vs. Redisson

Scalability and asynchronous and reactive support are some of the biggest selling points for Lettuce. However, Lettuce also comes with a few substantial disadvantages, including a steeper learning curve than other Redis Java clients. In addition, Lettuce is a fairly low-level abstraction, which means that it's not packed with features that some other Redis Java libraries have to offer.

Redisson, on the other hand, makes lowering the learning curve one of its primary objectives. By implementing a rich variety of Java objects and collections, Redisson makes it easier than ever to build powerful key-value databases in Redis.

Although the near cache in the base version of Redis was slower than that of Hazelcast, he found that installing Redisson made Redis faster than Hazelcast. In addition, "our production environment remained 100 percent stable with much less manual operation effort."

In the next section, we'll discuss some of the specific ways in which Redisson has the advantage over Lettuce.

Why Redisson is the Best Lettuce Replacement

1. Distributed objects, collections, and locks and synchronizers

In terms of Java distributed objects and collections, Lettuce is a fairly bare-bones implementation as compared with Redisson.

First, Lettuce supports the following Java distributed collections with plain commands only:

  • Map
  • Set
  • List
  • Queue
  • Deque
  • ScoredSortedSet
  • Stream

The Lettuce feature set also includes Java distributed objects such as:

  • Object holder
  • AtomicLong
  • Publish/Subscribe
  • AtomicDouble
  • Geospatial
  • BitSet
  • HyperLogLog

Redisson offers all of the above classes and more, including:

  • Multimap
  • SortedSet
  • PriorityQueue
  • PriorityDeque
  • DelayedQueue
  • RingBuffer
  • TransferQueue
  • Lock
  • Semaphore
  • CountDownLatch
  • FairLock
  • MultiLock
  • ReadWriteLock
  • BloomFilter
  • BinaryStream
  • RateLimiter

In particular, note that Redisson implements multiple options for distributed locks and synchronizers, while Lettuce has no such implementations.

2. Caching performance

By caching database queries and computations, you can massively improve your speed and performance, which is crucial for high volumes of data and high periods of activity. If caching is important to your database, then Redisson is the clear winner.

Only Redisson offers a JCache API to help you perform caching in Java. In addition, Redisson offers a "near cache" which stores frequently accessed data on the heap, improving caching performance even further (up to 45 times faster). Redisson also supports multiple caching strategies, including read-through, write-through, and write-behind.

Lettuce, however, includes neither a JCache API nor a near cache. If you want to perform caching in Lettuce, you'll have to build the system yourself, which can be both time-consuming and technically demanding.

3. Distributed services

Redis allows users to build a distributed system across multiple machines. Remote procedure calls (RPCs) are a distributed computing technique for executing a procedure on a remote machine, without having to know any details about that machine.

Lettuce does not include any support for distributed services out of the box. Redisson, meanwhile, implements the following Java distributed services:

  • RemoteService: Java Remote Method invocation.
  • LiveObjectService: Creating "live objects", which are enhanced Java objects that can be shared across different Java Virtual Machines (JVMs) and different computers.
  • ExecutorService: Managing the progress and termination of asynchronous Java tasks.
  • ScheduledExecutorService: Scheduling Java tasks periodically or after a given delay.
  • MapReduce: Implementing the MapReduce programming model for processing very large quantities of data.
4. Custom data serialization

Serializing data before sending it over a network is a best practice for database management - but which serialization codec should you use? The good news is that with Redis, you don't have to choose.

Redisson supports many different custom data serialization codecs, including: JDK, JSON, Avro, Smile, CBOR, MsgPack, Kryo, FST, LZ4 compression, and Snappy compression. Lettuce does not support any of the above codecs, although it does include limited serialization support with codecs such as ByteArrayCodec and StringCodec.

Similar articles