Docs

Java

Jedis and Spring Boot (cache and sessions).

Each example reads the connection URL from VALKEY_URL; copy it from your instance page in the dashboard. See connection details and limits for what applies to every client.

On this page: Jedis · Spring Boot

Jedis

Add the redis.clients:jedis dependency, version 7.2 or newer (Maven or Gradle). RedisClient takes the rediss:// URL directly and keeps a connection pool. On older versions, use JedisPooled the same way; Jedis 8 removed it.

App.java
import java.net.URI; import redis.clients.jedis.RedisClient; public class App {    public static void main(String[] args) {        try (RedisClient jedis = RedisClient.create(URI.create(System.getenv("VALKEY_URL")))) {            jedis.setex("greeting", 60, "hello");            System.out.println(jedis.get("greeting"));        }    }}

Spring Boot

With spring-boot-starter-data-redis, a rediss:// URL is all Spring Boot needs; TLS turns on from the scheme. Add spring-boot-starter-cache to use @Cacheable.

application.properties
spring.data.redis.url=${VALKEY_URL}spring.cache.type=redisspring.cache.redis.time-to-live=10m # Only with Spring Session: CONFIG is disabled on KVNest, so don't let# Spring try to enable keyspace notifications.spring.session.redis.configure-action=none
GreetingService.java
import org.springframework.cache.annotation.Cacheable;import org.springframework.stereotype.Service; @Servicepublic class GreetingService {    @Cacheable("greetings")    public String greet(String name) {        return "Hello, " + name;    }}
Remember @EnableCaching on a configuration class.

© 2026 KVNest · Managed Redis and Valkey, hosted in the EU

Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. KVNest is not affiliated with or endorsed by Redis Ltd.