AppFabric客户端的一些配置(Microsoft.Web.DistributedCache)

news/2024/7/8 7:33:09

通过使用Microsoft.Web.DistributedCache可直接将AppFabric Cache用于Session与Cache存储。直接贴配置,很简单。

1、配置configSections, 在configurtion节点下添加以下节点内容:

configSections
<!-- configSections must be the FIRST element  -->

< configSections >
   
  
<!--  required to read the <dataCacheClient> element  -->

< section
   
name ="dataCacheClient"
  
   type
="Microsoft.ApplicationServer.Caching.DataCacheClientSection,            Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"

         
   allowLocation
="true"
         
   allowDefinition
="Everywhere" />

</ configSections >

 

2、configSections节点后添加dataCacheClient节点配置

dataCacheClient
<!--  cache client  -->

< dataCacheClient >
 
  
<!--  cache host(s)  -->

  
< hosts >

    
< host
       
          
name ="CacheServer1"
   
          cachePort
="22233" />

  
</ hosts >

</ dataCacheClient >

 

3、system.web元素下添加以下配置

代码
< sessionState
     
mode ="Custom"
     customProvider
="AppFabricCacheSessionStoreProvider" >
  
< providers >
    
<!--  specify the named cache for session data  -->
    
< add 
        
name ="AppFabricCacheSessionStoreProvider"
         type
="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider"
         cacheName
="NamedCache1"
      sharedId
="SharedApp" />
  
</ providers >
</ sessionState >

 

以下是一个完整的配置示例:

完整示例
<? xml version="1.0" encoding="utf-8"  ?>
< configuration >
  
<!-- configSections must be the FIRST element  -->
  
< configSections >
     
<!--  required to read the <dataCacheClient> element  -->
     
< section
 
name ="dataCacheClient"
         type
="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
            Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"

         allowLocation
="true"
         allowDefinition
="Everywhere" />
  
</ configSections >  
  
<!--  cache client  -->
  
< dataCacheClient >
    
<!--  cache host(s)  -->
    
< hosts >
      
< host
         
name ="CacheServer1"
         cachePort
="22233" />
    
</ hosts >
  
</ dataCacheClient >
  
< system.web >
    
< sessionState  mode ="Custom"  customProvider ="AppFabricCacheSessionStoreProvider" >
      
< providers >
        
<!--  specify the named cache for session data  -->
        
< add
          
name ="AppFabricCacheSessionStoreProvider"  
          type
="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider"  
          cacheName
="NamedCache1"
          sharedId
="SharedApp" />
      
</ providers >
    
</ sessionState >
  
</ system.web >
</ configuration >

 

 如果要用做默认的缓存提供程序,只需要在System.Web里面增加Cache相关的节点配置点配置即可,示例如下:

代码
< caching >
      
< outputCache  defaultProvider ="AppFabric" >
        
< providers >
          
< add
             
name ="AppFabric"
type
="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider,Microsoft.Web.DistributedCache"
 cacheName
="default"   />
        
</ providers >
      
</ outputCache >
    
</ caching >

 

相关下载:/Files/zsea/AppFribc.zip

转载于:https://www.cnblogs.com/zsea/archive/2010/08/27/1809867.html


http://www.niftyadmin.cn/n/1122493.html

相关文章

使用Maven构建项目

Maven 是什么&#xff1f; Maven项目对象模型(POM)&#xff0c;可以通过一小段描述信息来管理项目的构建&#xff0c;报告和文档的软件项目管理工具。 Maven 除了以程序构建能力为特色之外&#xff0c;还提供高级项目管理工具。由于 Maven 的缺省构建规则有较高的可重用性&…

linux下redis安装

安装环境&#xff1a; linux&#xff1a;centos6.9 64位 redis版本&#xff1a;redis-4.0.2.tar.gz Redis安装 redis官网地址&#xff1a;http://www.redis.io/ 目前最新版本是4.0.2 1、下载源码&#xff0c;解压后编译源码 [rootlocalhost ~]# wget http://download.redis.io/…

RenderMonkey 练习 第一天 【opengl 纹理】

础实例&#xff1a; 我们首先实现一个带纹理模型的显示&#xff0c;大体了解RenderMonkey的操作方式。 1. 打开RenderMonkey, 右击WorkSpace的Effect WorkSpace结点&#xff0c;选择Add Default Effect->OPENGL->OPENGL&#xff0c; 创建一个基础实例。 2. 添加一张纹理…

batocera_batocera影音游戏主机系统,必须掌握的一些使用技巧

(三) batocera影音游戏主机系统&#xff0c;必须掌握的一些使用技巧在前面我们介绍了batocera这个支持上玩款游戏&#xff0c;和KODI中心的开源的影音游戏主机系统&#xff0c;和它在PC上的安装方法。现在&#xff0c;我们来说说batocera系统在使用中必须掌握的一些技巧。【1】…

在RHEL5下构建Samba文件共享服务器

一.samba服服务的安装在RHEL5系统的安装光盘中&#xff0c;与samba相关的软件包有五个&#xff1a;1.samba-3.0.23c-2.i386.rpm //服务器程序文件2.samba-client-3.0.33-3.14.el5.i386.rpm //客户端程序文件3.samba-common-3.0.33-3.14.el5.i386.rpm //服务器…

对个人来讲,什么事情越有趣,这件事情对社会的价值就越大

对个人来讲&#xff0c;什么事情越有趣&#xff0c;这件事情对社会的价值就越大&#xff1b; 对个人来讲&#xff0c;什么事情越烦恼&#xff0c;这件事情对社会的危害也越大。 确实挺有道理。 本文转自张昺华-sky博客园博客&#xff0c;原文链接&#xff1a;http://www.cnblog…

grep 多条件并行满足_grep多个条件

曾经希望用grep来搜索多个条件的时候&#xff0c;发现不知道怎么用&#xff0c;百度之后有以下两种1. AND条件使用 -E pattern1.*pattern2实现AND操作。grep -E pattern1.*pattern2 filename grep -E pattern1.*pattern2|pattern2.*pattern1 filename第一个例子如下&#xff1a…

C#保留2位小数几种场景总结

C#保留2位小数几种场景总结 场景1&#xff1a; C#保留2位小数&#xff0c;.ToString("f2")确实可以&#xff0c;但是如果这个数字本来就小数点后面三位比如1.253&#xff0c;那么转化之后就会变成1.25.可不可以刚好保留到最后一位不是0的位置&#xff1f;默认保留2位…