days
-1
0
hours
-1
-2
minutes
-1
-7
seconds
-3
-8
search
A healthier alternative for Redis Java client

Lettuce: Asynchronous support for Redis

Jane Elizabeth
Lettuce
© Shutterstock / Ekaterina Kondratova

Are you getting your regular servings of vegetables? This scalable, thread-safe Redis client isn’t just rabbit food; Lettuce supports synchronous, asynchronous, and reactive usage of the Redis API.

Is your Redis use on a diet? Sustain your hunger for multiple thread usage with Lettuce, a Redis Java client built to support your data-hungry needs.

Redis is a popular data structure store that is used as a database, cache, or message broker for Java. In Redis, data can be added, queried, modified, and deleted with commands that operate on keys in Redis’ in-memory data structure.

Why pick Lettuce?

If you’re looking for a client library for Redis, there are other options like Jedis and Reddison. In particular, Jedis is quite popular due to its lightweight size, powerful performance, and connection to the Spring Framework. However, neither of these two client libraries offers developers the kind of rich features and adaptable support that Lettuce does.

Lettuce is an open source and scalable thread-safe Redis client. Most importantly, it offers significant support for synchronous, asynchronous, and reactive usage. In particular, it manages its asynchronous support out of the box via Java 8’s CompletionStage interface. Developers can easily make asynchronous requests from the Redis database or create streams thanks to Lettuce’s natural interface.

Developers can take advantage of multiple threads utilizing the same connection if they can avoid blocking and transactional operations. Additionally, Lettuce supports advanced Redis features like sentinel, cluster, pipelining, auto-reconnect, and Redis data models. Plus, it can reconnect inactive connections.

Lettuce uses Netty to communicate with the server. While this does add weight to the API, it also makes Lettuce more suitable for multi-thread connections.

After a bit of a hiatus, Lettuce has recently been forked again on GitHub thanks to the dedicated work of some fans of the leafy green. Other notable changes for Lettuce include:

  • API Preview for Redis Streams
  • Asynchronous pool implementation
  • SCAN streams, and initial
  • Global command timeouts (disabled by default)
  • Asynchronous connect methods for Master/Slave and Sentinel
  • And more!

SEE ALSO: Redis 3.0.0 is here: Clustering!

Take a bite and try Lettuce

Interested in trying out Lettuce? You can download Lettuce via Maven, Ivy, and Gradle. There’s also a plain Java download here. More information is available on GitHub and Baeldung.

Contributions are indeed welcome. Feel free to dig right in and help!

Author
Jane Elizabeth
Jane Elizabeth is an assistant editor for JAXenter.com.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of