Redis Java client for Azure Cache

What is Azure Cache for Redis?

Redis is one of the most popular software projects for storing data structures in-memory. Microsoft's Azure Cache for Redis is a "fully managed, open source-compatible in-memory data store" for use with Redis that is available via the Microsoft Azure cloud computing platform. Azure Cache for Redis combines the rich feature set of Redis with the stability and support of Microsoft's cloud platform.

As a fully managed Redis solution, Azure Cache for Redis includes built-in features for performance, scalability, and security. This makes it a highly convenient option for users of Azure's cloud computing services who want to get up and running with Redis right away. Users can configure Azure Cache for Redis to automatically create and manage instances of Redis as needed, while enjoying all of the same features as the original Redis solution.

Redisson: a Redis Java client for Azure Cache

Many Redis users want to combine it with the Java programming language; however, Redis doesn't include support for Java out of the box. To integrate Redis with Java, you can rely on a third-party Redis Java client such as Redisson.

Redisson is a thread-safe Redis Java client library that takes advantage of many of the core principles of the Java programming language. It includes support for all of the most popular Java data structures and collections: Lists, Maps, Queues, Locks, Semaphores, and much more.

The original Redis API can be difficult to learn for newcomers, with more than 400 different commands to worry about. However, the same isn't true for Redisson. Thanks to Redisson's use of all the familiar concepts and interfaces in Java, you can get started with the Redisson library immediately without a learning curve.

To get a sense for just how easy it is to begin using Redisson, see the example code below:

package redis.demo;

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

public class Application 
{
    public static void main( String[] args )
    {
        Config config = new Config();
        config.useSingleServer()
              .setAddress("redis://test.redis.cache.windows.net: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();
    }
}

As you can see in the example above, Redisson is capable of using familiar Java interfaces such as RBucket and RMap in a distributed and concurrent implementation. RMap extends the original Map interface in Java, while RBucket provides a universal container and API for working with any type of object.

Redisson comes in two editions that can fit the needs of every business:

  • The open-source Redisson project includes support for distributed objects, collections, locks, synchronizers, and services. It also includes Asynchronous, Reactive Streams, and RxJava2 APIs and integrates with popular frameworks such as Spring Cache, Hibernate Cache, and Tomcat Session Manager.
  • Redisson PRO edition includes all of the functionality of the open-source version, as well as additional features to improve ease of use and performance. When compared with open-source Redisson in a benchmark environment, Redisson PRO exhibited significantly better throughput and lower execution times.

Use Redis commands mapping table to find Redisson method for a particular Redis command.

Similar articles