您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.
用于 Java 的 Redis 缓存库Redis Cache libraries for Java
07/11/2017
本文内容
概述Overview
Azure Redis 缓存是基于流行开源 Redis 缓存的安全分布式键值存储。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
使用开源 Jedis 客户端连接到 Azure Redis 缓存并在缓存中存储和检索值。Connect to Azure Redis Cache and store and retrieve values from the cache using the open-source Jedis client.
向 Maven pom.xml 文件中添加依赖项,以便在项目中使用客户端库。Add a dependency to your Maven pom.xml file to use the client library in your project.
redis.clients
jedis
2.9.0
jar
示例Example
连接到 Azure Redis 并在缓存中插入字符串。Connect to Azure Redis and insert a string into the cache.
JedisShardInfo shardInfo = new JedisShardInfo(".redis.cache.windows.net", 6380, useSsl);
shardInfo.setPassword(""); /* Use your access key. */
Jedis jedis = new Jedis(shardInfo);
jedis.set("foo", "bar");
管理 APIManagement API
使用管理 API 创建和缩放 Azure Redis 资源及管理访问密钥。Create and scale Azure Redis resources and manage access keys to with the management API.
com.microsoft.azure
azure-mgmt-redis
1.3.0
示例Example
在双节点标准层中创建新的 Azure Redis 缓存。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