Java client for Redis on SAP BTP

Published on
March 31, 2025

SAP Business Technology Platform (SAP BTP) is a business-focused platform as a service (PaaS) for developing, deploying, and managing enterprise applications. SAP BTP includes the popular in-memory data store Redis, implemented via the redis-cache service. 

Java programmers might want to work directly with redis-cache on SAP BTP, but the language doesn't natively support Redis. However, the Redis client Redisson allows Java developers to interact with redis-cache via familiar objects, classes, and methods. Here's how to set up Redisson, the Java client for Redis on SAP BTP.

What Is SAP BTP?

SAP BTP is a comprehensive PaaS environment from business software provider SAP. The platform focuses on application development and includes several database, automation, and integration services. SAP BTP helps accelerate digital transformation efforts with tools to build, extend, and automate business applications.

What Is Redis Hyperscaler Option on SAP BTP?

Redis Hyperscaler Option is a service on SAP BTP that allows business apps to utilize Redis cache services offered by cloud providers (hyperscalers) such as AWS. The service gives developers access to Redis for caching and other use cases within their SAP BTP applications.

Using Redisson, the Java client for Redis on SAP BTP  

Redisson is an open-source Java client that brings support for Redis to Java. With Redisson, developers can interact with Redis via familiar methods, classes, and objects. In the code example below, you will see how Redisson makes it easy to connect to SAP BTP's Redis Hyperscaler Option service.

This code makes use of two Redisson objects. First, RBucket is a general-purpose container for objects with a maximum size of 512 MB. Next, RMap is a map data structure to store objects. A value is associated with each key in the map.

Now, here is the code sample:

package redis.demo;

import org.redisson.Redisson;
import org.redisson.api.RBucket;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;

public class Application {

 public static void main(String[] args) {

     Config config = new Config();
     config.useSingleServer()
     .setAddress("redis://clustercfg.rg-abcd.vzhfku.use1.cache.amazonaws.com:6379");

     RedissonClient redisson = Redisson.create(config);

     // perform operations
     RBucket bucket = redisson.getBucket("simpleObject");
     bucket.set("This is object value");
     RMap map = redisson.getMap("simpleMap");
     map.put("mapKey", "This is map value");
            
     String objectValue = bucket.get();
     System.out.println("stored object value: " + objectValue);
     String mapValue = map.get("mapKey");
     System.out.println("stored map value: " + mapValue);

     redisson.shutdown();
 }
}

In addition, Redisson's cluster mode can be configured with one line of Java code:

ClusterServersConfig clusterConfig = config.useClusterServers();

More About Redisson and Redisson PRO

Redisson and Redisson PRO are the Redis clients for Java developers, whether you use it for SAP BTP's Redis Hyperscaler Option service or other cloud platforms. By adding classes, objects, and methods similar to native Java code, Redisson and Redisson PRO make it easy for Java developers to use Redis or Valkey as a cache, database, message broker, and other functions. To learn more, check out the feature comparison between Redisson and Redisson PRO.