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

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

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

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

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

Microsoft Distributed Cache Velocity 分布式缓存

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

     new-cache -cachename testcache

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

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

 

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

  和

 

[xhtml] view plaincopy
  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 plaincopy
  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

相关文章:

  • 2021-09-07
  • 2021-12-03
  • 2022-12-23
  • 2018-07-22
  • 2022-01-02
  • 2021-07-26
  • 2021-09-09
猜你喜欢
  • 2021-03-12
  • 2022-12-23
  • 2022-12-23
  • 2022-03-09
  • 2022-01-07
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案