zoukankan      html  css  js  c++  java
  • AppFabric客户端的一些配置(Microsoft.Web.DistributedCache)

    通过使用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

  • 相关阅读:
    团队项目-第一阶段冲刺7
    团队项目-第一阶段冲刺6
    Spring Boot 揭秘与实战(七) 实用技术篇
    Spring Boot 揭秘与实战(七) 实用技术篇
    Spring Boot 揭秘与实战(六) 消息队列篇
    Spring Boot 揭秘与实战(五) 服务器篇
    Spring Boot 揭秘与实战(五) 服务器篇
    Spring Boot 揭秘与实战(五) 服务器篇
    Spring Boot 揭秘与实战(五) 服务器篇
    Spring Boot 揭秘与实战(四) 配置文件篇
  • 原文地址:https://www.cnblogs.com/zsea/p/1809867.html
Copyright © 2011-2022 走看看