0

我们不想为此使用缓存集群,因为到目前为止,我们在缓存集群上面临一些稳定性问题,因此它们一直在维护(完全是我们的错)。我们可以使用专用集群进行会话存储吗?(忘记集群,至少一台主机?)

这就像在同一个应用程序中使用两个集群,一个用于缓存,一个用于会话存储,它们将位于同一个配置文件中。

我的做法对吗?任何帮助,将不胜感激。谢谢!

感谢@Cyber​​Max,我能够设置这个环境。但是,当我运行页面时出现错误:

无法读取配置部分“dataCacheClients”,因为它缺少部分声明

500内部服务器错误

这是我的配置:

<configuration>
  <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>

  <system.web>
<compilation debug="true" targetFramework="4.0">
  <assemblies>
    <add assembly="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add assembly="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </assemblies>
</compilation>
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
  <providers>
    <!--specify the named cache for session data-->
    <add name="AppFabricCacheSessionStoreProvider"  type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" cacheName="sample-cache" dataCacheClientName="VirtualCache"/>
  </providers>
</sessionState>

 </system.web>


 <dataCacheClients>
   <dataCacheClient name="serverCache">
     <localCache isEnabled="false" sync="NotificationBased" objectCount="100000"/>
     <clientNotification pollInterval="5"/>
     <!--cache host(s)-->
     <hosts>
       <host name="!@13452662.gf.com" cachePort="22233"/>
       <host name="!@13452663.gf.com" cachePort="22233"/>
     </hosts>
     <securityProperties mode="None" protectionLevel="None" />
     <transportProperties maxBufferPoolSize="2147483647" maxBufferSize="2147483647" channelInitializationTimeout="60000" receiveTimeout="900000"/>
    </dataCacheClient>

   <dataCacheClient name="VirtualCache">
     <localCache isEnabled="false" sync="NotificationBased" objectCount="100000"/>
     <clientNotification pollInterval="5"/>
    <hosts>
       <host name="localhost" cachePort="22233"/>
       <host name="localhost" cachePort="22234"/>
       <host name="localhost" cachePort="22235"/>
       <host name="localhost" cachePort="22236"/>
    </hosts>
   </dataCacheClient>
</dataCacheClients>
</configuration>

编辑 :

更改dataCacheClientdataCacheClients导致此错误:

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

 Parser Error Message: Web configuration error. Check your Web.config file, or revert to     the last working version.dataCacheClientName

Source Error: 



Line 31:       <providers>
Line 32:         <!--specify the named cache for session data-->
Line 33:         <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" cacheName="sample-cache" dataCacheClientName="VirtualCache"/>
Line 34:       </providers>
Line 35:     </sessionState>
4

1 回答 1

1

是的你可以。

当您配置 AppFabric 会话状态提供程序时,您可以提供一个 dataCacheClient 名称。它是 dataCacheClients 配置部分中要使用的 dataCacheClient 部分的名称。默认情况下,提供者将使用名为“default”的 dataCacheClient 部分。

, 如

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" compressionEnabled="false">
      <providers>
        <add name="AppFabricCacheSessionStoreProvider"
             type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
             cacheName="default"
             useBlobMode="true"
             dataCacheClientName="dataCacheClient1"/>
      </providers>
    </sessionState>

您的配置文件中可以有多个 dataCacheClient。

 <dataCacheClients>
    <dataCacheClient name="dataCacheClient1">
      <hosts>
        <host name="CacheServer1" cachePort="22233" />
      </hosts>
    </dataCacheClient>
    <dataCacheClient name="dataCacheClient2">
      <hosts>
        <host name="CacheServer1" cachePort="22233" />
      </hosts>
    </dataCacheClient>
  </dataCacheClients>

因此,拥有多个缓存集群是没有问题的。

编辑 :

这里是 AppFabric 1.0 的配置

<?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>

这里是 AppFabric 1.1 的配置

<?xml version="1.0"?>

<configuration>
  <configSections>
    <section name="dataCacheClients"
             type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core"
             allowLocation="true" allowDefinition="Everywhere"/>
  </configSections>

  <dataCacheClients>
    <dataCacheClient name="default" channelOpenTimeout="10000">
      <hosts>
        <host name="CacheServer1" cachePort="22233" />
      </hosts>
    </dataCacheClient>
  </dataCacheClients>

  <system.web>
    <sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" compressionEnabled="false">
      <providers>
        <add name="AppFabricCacheSessionStoreProvider"
             type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
             cacheName="default"
             useBlobMode="true"
             dataCacheClientName="default"/>
      </providers>
    </sessionState>
  </system.web>
</configuration>
于 2013-06-03T07:57:52.600 回答