MCPcopy Index your code
hub / github.com/redis/lettuce

github.com/redis/lettuce @7.6.0.RELEASE sqlite

repository ↗ · DeepWiki ↗ · release 7.6.0.RELEASE ↗
19,950 symbols 99,725 edges 1,605 files 8,136 documented · 41%
README

Lettuce - Advanced Java Redis client

Integration codecov MIT licensed Maven Central Javadocs

Discord Twitch YouTube Twitter Stack Exchange questions

Lettuce is a scalable thread-safe Redis client for synchronous, asynchronous and reactive usage. Multiple threads may share one connection if they avoid blocking and transactional operations such as BLPOP and MULTI/EXEC. Lettuce is built with netty. Supports advanced Redis features such as Sentinel, Cluster, Pipelining, Auto-Reconnect and Redis data models.

This version of Lettuce has been tested against the latest Redis source-build.

See the reference documentation and API Reference for more details.

How do I Redis?

Learn for free at Redis University

Try the Redis Cloud

Dive in developer tutorials

Join the Redis community

Work at Redis

Documentation

Binaries/Download

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Releases of lettuce are available in the Maven Central repository. Take also a look at the Releases.

Example for Maven:

<dependency>
  <groupId>io.lettuce</groupId>
  <artifactId>lettuce-core</artifactId>
  <version>x.y.z</version>
</dependency>

If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.

<dependency>
  <groupId>io.lettuce</groupId>
  <artifactId>lettuce-core</artifactId>
  <version>x.y.z.BUILD-SNAPSHOT</version>
</dependency>

<repositories>
  <repository>
    <id>sonatype-snapshots</id>
    <name>Sonatype Snapshot Repository</name>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>

Basic Usage

RedisClient client = RedisClient.create("redis://localhost");
StatefulRedisConnection<String, String> connection = client.connect();
RedisStringCommands sync = connection.sync();
String value = sync.get("key");

Each Redis command is implemented by one or more methods with names identical to the lowercase Redis command name. Complex commands with multiple modifiers that change the result type include the CamelCased modifier as part of the command name, e.g. zrangebyscore and zrangebyscoreWithScores.

See Basic usage for further details.

Asynchronous API

StatefulRedisConnection<String, String> connection = client.connect();
RedisStringAsyncCommands<String, String> async = connection.async();
RedisFuture<String> set = async.set("key", "value");
RedisFuture<String> get = async.get("key");

LettuceFutures.awaitAll(set, get) == true

set.get() == "OK"
get.get() == "value"

See Asynchronous API for further details.

Reactive API

StatefulRedisConnection<String, String> connection = client.connect();
RedisStringReactiveCommands<String, String> reactive = connection.reactive();
Mono<String> set = reactive.set("key", "value");
Mono<String> get = reactive.get("key");

set.subscribe();

get.block() == "value"

See Reactive API for further details.

Pub/Sub

RedisPubSubCommands<String, String> connection = client.connectPubSub().sync();
connection.getStatefulConnection().addListener(new RedisPubSubListener<String, String>() { ... })
connection.subscribe("channel");

Building

Lettuce is built with Apache Maven. The tests require multiple running Redis instances for different test cases which are configured using a Makefile. Tests run by default against Redis latest.

To build:

$ git clone https://github.com/redis/lettuce.git
$ cd lettuce/
$ make start
  • Run the build: make test
  • Start Redis (manually): make start
  • Stop Redis (manually): make stop
  • Clean up: make clean

Bugs and Feedback

For bugs, questions and discussions please use the GitHub Issues.

License

  • This repository is licensed under the "MIT" license. See LICENSE.
  • Fork of https://github.com/wg/lettuce

Contributing

Github is for social coding: if you want to write code, I encourage contributions through pull requests from forks of this repository. Create Github tickets for bugs and new features and comment on the ones that you are interested in and take a look into CONTRIBUTING.md

Extension points exported contracts — how you extend this code

MaintenanceNotificationCapture (Interface)
Interface for capturing Redis Enterprise maintenance event notifications. This allows different capture implementations [10 …
src/test/java/io/lettuce/scenario/MaintenanceNotificationCapture.java
CompositeArgument (Interface)
Interface for composite command argument objects. Implementing classes of CompositeArgument consolidate multiple [153 …
src/main/java/io/lettuce/core/CompositeArgument.java
VoidWaitCondition (Interface)
(no doc) [3 implementers]
src/test/java/io/lettuce/test/Wait.java
RedisConnectionStateListener (Interface)
Simple interface for Redis connection state monitoring. @author ze @author Mark Paluch [7 implementers]
src/main/java/io/lettuce/core/RedisConnectionStateListener.java
Sleeper (Interface)
(no doc) [2 implementers]
src/test/java/io/lettuce/test/Wait.java
Nodes (Interface)
Descriptor of nodes that are available for the current read operation. [9 implementers]
src/main/java/io/lettuce/core/ReadFrom.java
ThrowingCallable (Interface)
(no doc)
src/test/java/io/lettuce/test/WithPassword.java
RedisChannelWriter (Interface)
Writer for a channel. Writers push commands on to the communication channel and maintain a state for the commands. @aut [12 …
src/main/java/io/lettuce/core/RedisChannelWriter.java

Core symbols most depended-on inside this repo

add
called by 2133
src/main/java/io/lettuce/core/json/JsonArray.java
get
called by 2096
src/test/java/io/lettuce/core/dynamic/RedisCommandsIntegrationTests.java
build
called by 1946
src/main/java/io/lettuce/core/AclSetuserArgs.java
put
called by 1184
src/main/java/io/lettuce/core/json/JsonObject.java
isTrue
called by 1155
src/main/java/io/lettuce/core/internal/LettuceAssert.java
notNull
called by 1080
src/main/java/io/lettuce/core/internal/LettuceAssert.java
set
called by 748
src/test/java/io/lettuce/core/dynamic/CommandSegmentCommandFactoryUnitTests.java
sync
called by 726
src/test/java/io/lettuce/core/dynamic/CommandSegmentCommandFactoryUnitTests.java

Shape

Method 17,603
Class 1,779
Interface 388
Enum 180

Languages

Java100%

Modules by API surface

src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java466 symbols
src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java460 symbols
src/main/java/io/lettuce/core/RedisCommandBuilder.java377 symbols
src/test/jmh/io/lettuce/core/protocol/EmptyByteBuf.java140 symbols
src/main/java/io/lettuce/core/dynamic/ReactiveTypeAdapters.java112 symbols
src/main/java/io/lettuce/core/AclSetuserArgs.java104 symbols
src/test/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImplUnitTests.java100 symbols
src/test/java/io/lettuce/scenario/MaintenanceNotificationConnectionTest.java88 symbols
src/test/java/io/lettuce/core/commands/SortedSetCommandIntegrationTests.java84 symbols
src/main/java/io/lettuce/core/RedisURI.java81 symbols
src/test/java/io/lettuce/core/RedisCommandBuilderUnitTests.java76 symbols
src/main/java/io/lettuce/core/RedisPublisher.java74 symbols

Dependencies from manifests, versioned

com.github.javaparser:javaparser-core3.6.3 · 1×
com.google.code.findbugs:jsr3053.0.2 · 1×
eu.rekawek.toxiproxy:toxiproxy-java2.1.11 · 1×
io.micrometer:micrometer-bom
io.micrometer:micrometer-core
io.micrometer:micrometer-observation
io.micrometer:micrometer-test
io.micrometer:micrometer-tracing
io.micrometer:micrometer-tracing-bom
io.micrometer:micrometer-tracing-integration-test
io.micrometer:micrometer-tracing-test

For agents

$ claude mcp add lettuce \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact