Skip to content

Getting Started

You can get started with Lettuce in various ways.

1. Get it

For Maven users

Add these lines to file pom.xml:

<dependency>
    <groupId>io.lettuce</groupId>
    <artifactId>lettuce-core</artifactId>
    <version>6.5.0.RELEASE</version>
</dependency>

For Ivy users

Add these lines to file ivy.xml:

<ivy-module>
  <dependencies>
    <dependency org="io.lettuce" name="lettuce-core" rev="6.5.0.RELEASE"/>
  </dependencies>
</ivy-module>

For Gradle users

Add these lines to file build.gradle:

dependencies {
  implementation 'io.lettuce:lettuce-core:6.5.0.RELEASE'
}

Plain Java

Download the latest binary package from https://github.com/redis/lettuce/releases and extract the archive.

2. Start coding

So easy! No more boring routines, we can start.

Import required classes:

import io.lettuce.core.*;

and now, write your code:

RedisClient redisClient = RedisClient.create("redis://password@localhost:6379/0");
StatefulRedisConnection<String, String> connection = redisClient.connect();
RedisCommands<String, String> syncCommands = connection.sync();

syncCommands.set("key", "Hello, Redis!");

connection.close();
redisClient.shutdown();

Done!

Do you want to see working examples?