2.4 KiB
2.4 KiB
title | description | keywords | author | ms.author | manager | ms.date | ms.topic | ms.prod | ms.technology | ms.devlang | ms.service |
---|---|---|---|---|---|---|---|---|---|---|---|
Redis Cache libraries for Java | Reference documentation for the Java client and management libraries for Redis Cache | Azure, Java, SDK, API, cache, redis, web cache, key-value, in-memory | rloutlaw | routlaw | douge | 07/11/2017 | reference | azure | azure | java | redis-cache |
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();
[!div class="nextstepaction"] Explore the Management APIs
Samples
Explore more sample Java code for Azure Redis Cache you can use in your apps.