AppFabric 使用
AppFabric的开发相对还是很简单的,最常见的方法无非是声明一个缓存接口,然后由各种缓存实现.
具体的使用除了msdn:
http://msdn.microsoft.com/zh-cn/library/hh334305
这是实例包的下载地址:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=19603
这篇博客介绍得不错.
使用微软分布式缓存服务Velocity(Windows Server AppFabric Caching Service)
概述
配置模型
<?xml version="1.0" encoding="utf-8"?> <configuration><configSections><section name="dcache" type="System.Data.Caching.DCacheSection, CacheBaseLibrary, Version=1.0.0.0, Culture=neutral,PublicKeyToken=89845dcd8080cc91" /></configSections><dcache cluster="localhost" size="Small"><caches><cache type="partitioned" consistency="strong" name="default"><policy><eviction type="lru" /><expiration defaultTTL="10" isExpirable="true" /></policy></cache><cache type="partitioned" consistency="strong" name="other"><policy><eviction type="lru" /><expiration defaultTTL="10" isExpirable="true" /></policy></cache></caches><hosts><host clusterPort="22234" hostId="1319514812" size="1024" quorumHost="true"name="TERRYLEE-PC" cacheHostName="DistributedCacheService"cachePort="22233" /></hosts><advancedProperties><partitionStoreConnectionSettings providerName="System.Data.SqlServerCe.3.5"connectionString="D:\CacheShare\ConfigStore.sdf" /></advancedProperties></dcache> </configuration>
<section name="dcacheClient" type="System.Data.Caching.DCacheSection, CacheBaseLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<dcacheClient><localCache isEnabled="true" sync="TTLBased" ttlValue="300" /><hosts><host name="localhost" cachePort="22233" cacheHostName="DistributedCacheService"/></hosts> </dcacheClient>
缓存复杂数据类型
[Serializable] public class Customer {public String ID { get; set; }public String FirstName { get; set; }public String LastName { get; set; }public int Age { get; set; }public String Email { get; set; } }
Cache cache = GetCurrentCache(); Customer customer = new Customer() {ID = "C20081117002",FirstName = "Terry",LastName = "Lee",Age = 25,Email = "lhj_cauc[#AT#]163.com" }; cache.Add(customer.ID, customer);
Cache cache = GetCurrentCache(); Customer customer = cache.Get("C20081117002") as Customer;
Cache cache = GetCurrentCache(); cache.Remove("C20081117002");
Cache cache = GetCurrentCache(); Customer customer = new Customer() {ID = "C20081117002",FirstName = "Huijui",LastName = "Li",Age = 26,Email = "lhj_cauc[#AT#]163.com" }; cache["C20081117002"] = customer;
Cache cache = GetCurrentCache(); Customer customer = new Customer() {ID = "C20081117002",FirstName = "Huijui",LastName = "Li",Age = 26,Email = "lhj_cauc[#AT#]163.com" }; cache.Put(customer.ID, customer);
使用分区
public void ClearRegion(string region); public bool CreateRegion(string region, bool evictable); public bool RemoveRegion(string region);
Cache cache = GetCurrentCache(); string regionName = "Customers"; cache.CreateRegion(regionName, false); Customer customer = new Customer() {ID = "C20081117003",FirstName = "Terry",LastName = "Lee",Age = 25,Email = "lhj_cauc[#AT#]163.com" }; cache.Add(regionName, customer.ID, customer);
使用标签
Cache cache = GetCurrentCache(); string regionName = "Customers"; Customer customer1 = new Customer() {ID = "C20081117004",FirstName = "Terry",LastName = "Lee",Age = 25,Email = "lhj_cauc[#AT#]163.com" }; Customer customer2 = new Customer() {ID = "C20081117005",FirstName = "Terry",LastName = "Lee",Age = 25,Email = "lhj_cauc[#AT#]163.com" }; Tag tag1 = new Tag("Beijing"); Tag tag2 = new Tag("Tianjin"); cache.Add(regionName, customer1.ID, customer1, new Tag[] { tag1, tag2 }); cache.Add(regionName, customer2.ID, customer2, new Tag[] { tag2 });
GetAllMatchingTags(string region, Tag[] tags) GetAnyMatchingTag(string region, Tag[] tags) GetByTag(string region, Tag tag)
string regionName = "Customers"; Tag[] tags = new Tag[] { new Tag("Beijing"), new Tag("Tianjin")}; List<KeyValuePair<string, object>> result= cache.GetAllMatchingTags(regionName, tags);
ASP.NET SessionState提供者
<section name="dcacheClient"type="System.Data.Caching.DCacheSection, CacheBaseLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<dcacheClient><localCache isEnabled="true" sync="TTLBased" ttlValue="300" /><hosts><host name="localhost" cachePort="22233" cacheHostName="DistributedCacheService"/></hosts> </dcacheClient>
<sessionState mode="Custom" customProvider="Velocity"><providers><add name="Velocity" type="System.Data.Caching.SessionStoreProvider,ClientLibrary"cacheName="default"/></providers> </sessionState>
总结
本文出自 “TerryLee技术专栏” 博客,请务必保留此出处http://terrylee.blog.51cto.com/342737/151964
AppFabric 使用相关推荐
- Windows Azure AppFabric概述
公告 :本博客为微软云计算中文博客 的镜像博客. 部分文章因为博客兼容性问题 ,会影响阅读体验 .如遇此情况,请访问 原博客 . Windows Azure AppFabric ...
- Windows Server AppFabric Caching
这套 AppFabric Caching 比我用过的 memcached 复杂多了,MSDN有一篇文章进行介绍Introduction to Caching with Windows Server A ...
- Windows Server AppFabric Beta 2 for For Vistual Studio 2010已经发布
Windows Server AppFabric Beta 2 For Vistual Studio 2010/.NET Framework 4.0已经发布了,参看EndPonit上的博客文章http ...
- AppFabric Caching Admin Tool
最近试用了一下MS的AppFabric的分布是缓存(Velocity),发现了一个不错的可视化配置工具挺有用,先介绍给大家,后续再详细介绍. http://mdcadmintool.codeplex. ...
- SharePoint2013安装组件时AppFabric时出现1603错误,解决方法:
采用PowerShell命令批量下载必备组件: 下载完成后,采用批处理命令安装必备组件. 注:SPS2013安装必备组件及批处理下载地址: 需要将必备组件放在安装文件的PrerequisiteInst ...
- Windows Server AppFabric Caching支持大数据量的配置
Memcache支持的数据量大小为1M,最新版本可以通过配置调整突破1M(参看http://www.cnblogs.com/shanyou/archive/2010/02/01/1661271.htm ...
- 使用AppFabric 承载WCF和WF服务-安装和使用
AppFabric 承载服务步骤 对于包含WCF和WF的服务,如果想长期的运行和管理维护,AppFabric无疑是个很好的选择.具体步骤: 参考http://www.cnblogs.com/2018/ ...
- AppFabric客户端的一些配置(Microsoft.Web.DistributedCache)
通过使用Microsoft.Web.DistributedCache可直接将AppFabric Cache用于Session与Cache存储.直接贴配置,很简单. 1.配置configSections ...
- SharePoint 2013必备组件离线包安装:AppFabric无法安装问题解决
SharePoint 2013必备组件离线包安装:AppFabric无法安装问题解决 参考文章: (1)SharePoint 2013必备组件离线包安装:AppFabric无法安装问题解决 (2)ht ...
- Windows Azure AppFabric 入门教学(七):多播(Multicast)
公告:本博客为微软云计算中文博客的镜像博客.部分文章因为博客兼容性问题,会影响阅读体验.如遇此情况,请访问原博客. 本文是Windows Azure AppFabric入门教学的第七篇文章.我们知道, ...
最新文章
- java handler类_java——Handler类
- Linux文字分段裁剪命令cut(转)
- C#中Lambda表达式类型Expression不接受lambda函数
- SMB MS17-010 利用(CVE-2017-0144 )
- win10开机时不显示锁屏壁纸
- linux 命令学习 —— 硬件外设管理(dmesg、lsusb)
- kafka/producer.lua:168: attempt to perform arithme
- 火山视窗类库静态编译一览表,以及所需求的vs版本
- 安装VirtualBox的虚拟机增强功能
- 8种经典的统计学悖论18种经典的哲学悖论
- 一小时看懂Ruby代码基本逻辑(自定义metasploit模块)
- Python--Turtle钟表
- python报错:Empty suite
- Android7工程模式,安卓手机进入各种工程模式快捷键小结
- 全国二级计算机考试准考证打印官网
- 电视连接WiFi中心服务器异常,网络电视登录失败怎么办?为什么电视连接wifi常常显示登陆失败?...
- 微信支付开发 认清微信支付v2和v3
- 《悲惨世界》--[法]雨果
- 《2023年金融科技趋势展望》发布,提出十大技术趋势
- python 拼音库_python有没有拼音库python进阶之socket详解