• 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

  • 相关阅读:
    JS中const的使用
    JS的作用域,闭包的理解
    python中函数的默认参数是空数组
    asp.net 导出 Excel
    asp.net 导出 Excel 身份证格式显示格式问题
    HTML5
    JQuery中checkbox选择器
    JQuery中DOM操作(一)
    PL/SQL 创建用户及权限操作
    PL/SQL 表约束
  • 原文地址:https://www.cnblogs.com/zsea/p/1809867.html
Copyright © 2020-2023  润新知