Redis Cache libraries for Java

Overview

Azure Redis Cache is a secure, distributed key-value store based on the popular open source Redis cache.

To get started with Azure Redis Cache, see How to use Azure Redis Cache with Java.

Client library

Connect to Azure Redis Cache and store and retrieve values from the cache using the open-source Jedis client.

Add a dependency to your Maven pom.xml file to use the client library in your project.

<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>2.9.0</version>
    <type>jar</type>
</dependency>

Example

Connect to Azure Redis and insert a string into the cache.

JedisShardInfo shardInfo = new JedisShardInfo("<name>.redis.cache.windows.net", 6380, useSsl);
    shardInfo.setPassword("<key>"); /* Use your access key. */
    Jedis jedis = new Jedis(shardInfo);
    jedis.set("foo", "bar");

Management API

Create and scale Azure Redis resources and manage access keys to with the management API.

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-mgmt-redis</artifactId>
    <version>1.3.0</version>
</dependency>

Example

Create a new Azure Redis Cache in the two-node standard tier.

RedisCache cache = azure.redisCaches().define(redisCacheName1)
    .withRegion(Region.US_CENTRAL)
    .withNewResourceGroup(rgName)
    .withStandardSku();

Samples

Manage Azure Redis Cache

Explore more sample Java code for Azure Redis Cache you can use in your apps.