Windows Azure 系列-- Azure Redis Cache的配置和使用
2024-10-21 06:05:21
假设还没有配置Azure Power shell 能够參照这里进行配置:
http://blog.csdn.net/lan_liang/article/details/46850221
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正在创建
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
3. 进入https://portal.azure.com/#create/Microsoft.Cache.1.0.4创建Cache
4. 点击菜单Redis Caches 能够看到redis已经创建好了:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" style="font-size:14px;" alt="" />
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
最新文章
- [转]从JVM角度看线程安全与垃圾收集
- 在Tomat7上使用Redis保存Session
- Model层数据验证
- mysql获取插入时自增ID值的方法
- js object(对象)
- jsp获取struts2查询到的数据
- Cannot connect to (local) sql server 2008
- iOS中UIWebView使用JS交互 - 机智的新手
- 老男孩Python全栈开发(92天全)视频教程 自学笔记03
- 使用JAXB解析xml文件(一)
- Numpy数组数据文件的读写
- css 积累
- Python assert(断言)
- T4 反射实体模型生成代码(Demo)
- 51nod1305
- 爬虫学习06用selenium爬取空间
- ubuntu16 配置git
- 5E - A + B Again
- Java虚拟机 - 结构原理与运行时数据区域
- java编码-多重(乱码)
热门文章
- git如何打补丁?
- httpd 服务的两个节点的HA
- crontab 写入文件目录
- 如何看待Linux操作系统的用户空间和内核空间
- http://zhidao.baidu.com/link?url=3tJ_i5gyYLrd7rFPk0eRYre_oxjCZvTOMOutp89LGhUgi6Ic6Ncama_GMAHnwfF73SVYGqy364vDfv6AY4ERPa
- XAMPP Apache + MySQL + PHP + Perl
- MyTools
- C#异常处理机制初步
- c和c++在windows下获取时间和计算时间差的方法总结
- CASE WHEN 的用法