Configure azure shared cache locally and on the cloud

情到浓时终转凉″ 提交于 2019-12-11 01:44:44

问题


I'm at a complete loss with getting the shared caching to work.

Locally, I've got an mvc4 site running and I created a cloud project from this. I enabled caching on the role and set this to be co-located. All fine so far.

I added the Windows Azure Caching 2.1 package from NuGet which installed the relevant libraries and also updated my web config:

configSections:

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

config:

<dataCacheClients>
<dataCacheClient name="default">
  <!--To use the in-role flavor of Windows Azure Caching, set identifier to be the cache cluster role name -->
  <!--To use the Windows Azure Caching Service, set identifier to be the endpoint of the cache cluster -->
  <autoDiscover isEnabled="true" identifier="" />
  <!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />-->
  <!--Use this section to specify security settings for connecting to your cache. This section is not required if your cache is hosted on a role that is a part of your cloud service. -->
  <!--<securityProperties mode="Message" sslEnabled="false">
    <messageSecurity authorizationInfo="[Authentication Key]" />
  </securityProperties>-->
</dataCacheClient>

When I follow the instructions and add the role name to identifer attribute on the autoDiscover element and run the app, it seems to just hang (I'm assuming failing) on this:

_cache = new DataCache("default");

I have the storage emulator running and the site debugging from the compute emulator. I just can't seem to get the site to work configured to use the azure cache.


回答1:


Please make sure that you're using SDK version 2.1. Caching 2.1 package will only work with the latest version of SDK (see the screenshot below). You may want to check out this thread here: Exception while using Windows Azure Caching : No such host is known



来源:https://stackoverflow.com/questions/18045279/configure-azure-shared-cache-locally-and-on-the-cloud

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