lettuce
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Lettuce is a Java library that lets applications talk to Redis, a popular in-memory data store often used for caching, session storage, and real-time features. The library is maintained by Redis and handles the low-level work of opening connections, sending commands, and receiving results.
What sets Lettuce apart from other Redis clients for Java is its support for three different programming styles in a single package. Synchronous usage means your code waits for each Redis command to finish before moving on, which is the simplest approach. Asynchronous usage means your code fires off commands and gets back a future object that will eventually contain the result, so other work can happen in the meantime. Reactive usage follows a stream-based model popular in modern Java frameworks, where you describe how to handle results when they arrive rather than waiting for them directly.
All three styles share the same underlying connection, which is designed to be safe for use across multiple threads without creating a separate connection per thread. The library also supports Redis Sentinel and Redis Cluster, which are two ways to run Redis across multiple servers for higher reliability or bigger data sets. It handles automatic reconnection if the connection drops, encrypted connections over SSL, and different ways to encode your data, such as JSON or custom binary formats.
For developers working with newer Redis features, the library includes support for RediSearch, RedisJSON, and Redis Vector Sets, which are add-ons that turn Redis into a search engine, a JSON document store, or a vector similarity store respectively.
The library is available through Maven Central, the standard package registry for Java projects, so adding it to an existing Java project is a matter of adding a few lines to a build configuration file.