Windows Azure 系列-- Azure Redis Cache的配置和使用
假设还没有配置Azure Power shell 能够參照这里进行配置:
http://blog.csdn.net/lan_liang/article/details/46850221
(假设已经加入就不用了)
2. 执行
进到Azure Cache页面,能够看到Cache正在创建
![](//img-blog.csdn.net/20150712145605435?</p><p>watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](//img-blog.csdn.net/20150712145622991?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
3. 进入https://portal.azure.com/#create/Microsoft.Cache.1.0.4创建Cache
![](//img-blog.csdn.net/20150712145616715?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
5. 安装nuget package
![](//img-blog.csdn.net/20150712145637231?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
6. Console Application的代码:
PrimaryKey在这里看:
![](//img-blog.csdn.net/20150712145643197?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
将代码中的"your_domain"替换为你的DNS。password替换为你的PrimaryKey
http://blog.csdn.net/lan_liang/article/details/46850221
打开Azure Power Shell
Add-AzureAccount
(假设已经加入就不用了)
2. 执行
New-AzureManagedCache -Name mycache -Location "South Central US" -Sku Basic -Memory 128MB
进到Azure Cache页面,能够看到Cache正在创建
3. 进入https://portal.azure.com/#create/Microsoft.Cache.1.0.4创建Cache
4. 点击菜单Redis Caches 能够看到redis已经创建好了:
5. 安装nuget package
6. Console Application的代码:
static void Main(string[] args) { ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("your_domain.redis.cache.windows.net,ssl=true,password=YourPrimaryKey"); IDatabase cache = connection.GetDatabase(); // Perform cache operations using the cache object... // Simple put of integral data types into the cache cache.StringSet("key1", "value"); cache.StringSet("key2", 25); // Simple get of data types from the cache string key1 = cache.StringGet("key1"); Console.WriteLine(key1); int key2 = (int)cache.StringGet("key2"); Console.WriteLine(key2); Console.Read(); }
PrimaryKey在这里看:
将代码中的"your_domain"替换为你的DNS。password替换为你的PrimaryKey