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

释放双眼,带上耳机,听听看~!

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

打开Azure Power Shell

  1. 运行

1
2
1Add-AzureAccount
2

1
2
1 (如果已经添加就不用了)  
2
  1. 运行 

1
2
1New-AzureManagedCache -Name mycache -Location "South Central US" -Sku Basic -Memory 128MB
2

1
2
1进到Azure Cache页面,可以看到Cache正在创建  
2
  1. 进入https://portal.azure.com/\#create/Microsoft.Cache.1.0.4创建Cache

  2. 点击菜单Redis Caches 可以看到redis已经创建好了:

  3. 安装nuget package

  4. Console Application的代码:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1static void Main(string[] args)
2        {
3            ConnectionMultiplexer connection =
4ConnectionMultiplexer.Connect("your_domain.redis.cache.windows.net,ssl=true,password=YourPrimaryKey");
5
6            IDatabase cache = connection.GetDatabase();
7
8            // Perform cache operations using the cache object...
9            // Simple put of integral data types into the cache
10            cache.StringSet("key1", "value");
11            cache.StringSet("key2", 25);
12
13            // Simple get of data types from the cache
14            string key1 = cache.StringGet("key1");
15            Console.WriteLine(key1);
16            int key2 = (int)cache.StringGet("key2");
17            Console.WriteLine(key2);
18
19            Console.Read();
20        }
21

1
2
1PrimaryKey在这里看:  
2

将代码中的"your_domain"替换为你的DNS,password替换为你的PrimaryKey

给TA打赏
共{{data.count}}人
人已打赏
安全运维

OpenSSH-8.7p1离线升级修复安全漏洞

2021-10-23 10:13:25

安全运维

设计模式的设计原则

2021-12-12 17:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索