Skip to content

Getting started

Mark Paluch edited this page Mar 13, 2024 · 17 revisions

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.3.2.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.3.2.RELEASE"/>
  </dependencies>
</ivy-module>

For Gradle users

Add these lines to file build.gradle:

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

Plain Java

Download the latest binary package from https://github.com/lettuce-io/lettuce-core/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?

Clone this wiki locally