Microsoft Distributed Cache Velocity 分布式缓存

微软分布式缓存,工程代码为“Velocity”。这是一个分布式内存对象缓存系统。最新版本为CTP3。下载

   跟memcached一样,“Velocity”维护一张大的哈希表,这张表可以跨越多个服务器,你可以通过添加或者减少服务器来平衡系统压力。

   安装“Velocity ”时需要建立一个保存配置的地方,可以是共享文件,也可以是SQLServer数据库。

   安装完成后需要用Run as administrator来运行它。

   接下来我们要启动它。命令为:start-cachecluster.

    然后加入一个新的Cache,名称为“testcache”.命令为:

     new-cache -cachename testcache

     下面我们要在系统中使用“Velocity ”。

      首先要引用CacheBaseLibrary.dll 和 ClientLibrary.dll。然后在配置文件中加入

 

[xhtml]  view plain copy
  1. <configSections>  
  2.   
  3. <section name="dataCacheClient" type="Microsoft.Data.Caching.DataCacheClientSection, CacheBaseLibrary" allowLocation="true" allowDefinition="Everywhere"/>   
  4.   
  5. </configSections>  

  和

 

[xhtml]  view plain copy
  1. <sessionState mode="Custom" customProvider="Velocity">  
  2.   
  3. <providers>  
  4.   
  5. <add name="Velocity" type="Microsoft.Data.Caching.DataCacheSessionStoreProvider, ClientLibrary" />  
  6.   
  7. </providers>  
  8.   
  9. </sessionState>  

 

   最后就是使用了,下面是

   加入一个缓存:

 

[c-sharp]  view plain copy
  1. DataCacheFactory dcf = new DataCacheFactory();  
  2. DataCache dcfcontrin = dcf.GetCache("testcache");  
  3. //加入一个,绝对过期时间为10秒  
  4. dcfcontrin.Add("test""ok",new TimeSpan (0,0,10));  

  还有其他方法 Put,Remove,Get.

   实例代码下载http://download.csdn.net/source/1915176

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值