码迷,mamicode.com
首页 > Windows程序 > 详细

Windows Azure 系列-- Azure Redis Cache的配置和使用

时间:2015-07-12 15:43:14      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

如果还没有配置Azure Power shell 可以参照这里进行配置:
http://blog.csdn.net/lan_liang/article/details/46850221

打开Azure Power Shell


1. 运行
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

版权声明:本文为博主原创文章,未经博主允许不得转载。

Windows Azure 系列-- Azure Redis Cache的配置和使用

标签:

原文地址:http://blog.csdn.net/lan_liang/article/details/46850249

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!