Using a mix of AppFabric local cache and server cache

寵の児 提交于 2020-01-03 16:49:03

问题


I'm just starting out using AppFabric...

My application is in healthcare - we have about 15000 users of the system and they access patient information in bursts (e.g. think of a team of nurses/doctors accessing a patient when they are hospitalized).

What I'd like to do is cache certain items (e.g. patient demographics info) in memory and other items (e.g. labs, medications, diagnostic imaging, reports) on the cache host server. The underlying data comes from various 3rd party systems, some of them extremely slow to return data.

Does anyone know if it is possible to indicate that certain items go into the local cache while others go to the server? There is too much data to all fit into memory. In looking at the MSDN documentation, here is a sample config file.

   <dataCacheClient requestTimeout="15000" channelOpenTimeout="3000" maxConnectionsToServer="1">
      <localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
      <clientNotification pollInterval="300" maxQueueLength="10000"/>
      <hosts>
         <host name="CacheServer1" cachePort="22233"/>
         <host name="CacheServer2" cachePort="22233"/>
      </hosts>
      <securityProperties mode="Transport" protectionLevel="EncryptAndSign" />
      <transportProperties connectionBufferSize="131072" maxBufferPoolSize="268435456" 
                           maxBufferSize="8388608" maxOutputDelay="2" channelInitializationTimeout="60000" 
                           receiveTimeout="600000"/>
   </dataCacheClient>

It looks like enabling local cache enables for the entire cache client?

To support the scenario I describe, does this mean I'll have to create two cache clients and my code will have to know / be aware of which cache client to put data into? Or is there an API/flag/parameter I can use at time of storing data into the cache? Or perhaps, handled by using Regions/Tags?

Thanks!


回答1:


Assuming you're using AppFabric 1.1, you can configure multiple dataCacheClient nodes with differing configurations. So using your existing example, you would do something like:

<!-- local caching client -->
<dataCacheClient name="LocalCaching" requestTimeout="15000" channelOpenTimeout="3000" maxConnectionsToServer="1">
  <localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
  <clientNotification pollInterval="300" maxQueueLength="10000"/>
  <hosts>
     <host name="CacheServer1" cachePort="22233"/>
     <host name="CacheServer2" cachePort="22233"/>
  </hosts>
  <securityProperties mode="Transport" protectionLevel="EncryptAndSign" />
  <transportProperties connectionBufferSize="131072" maxBufferPoolSize="268435456" 
                       maxBufferSize="8388608" maxOutputDelay="2" channelInitializationTimeout="60000" 
                       receiveTimeout="600000"/>

Then from code you have different DataCacheFactoryConfigurations using the constructor that takes a name instead of just using the default:

DataCacheFactoryConfiguration localCachingFactoryConfig = new DataCacheFactoryConfiguration("LocalCaching");

DataCacheFactoryConfiguration remoteOnlyCachingFactoryConfig = new DataCacheFactoryConfiguration("RemoteOnlyCaching");

Then you just create your DataCache instances from the appropriate factory in code based on which type of caching you require for the data you're working with.



来源:https://stackoverflow.com/questions/12963103/using-a-mix-of-appfabric-local-cache-and-server-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!