在本地和云上配置azure共享缓存

时间:2013-08-04 16:55:05

标签: c# azure shared-cache

我完全失去了共享缓存的功能。

在本地,我有一个mvc4网站正在运行,我从中创建了一个云项目。我在角色上启用了缓存,并将其设置为共处。到目前为止一切都很好。

我从NuGet添加了Windows Azure Caching 2.1软件包,它安装了相关的库并更新了我的web配置:

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" />

配置

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

          

当我按照说明操作并将角色名称添加到identifer元素上的autoDiscover属性并运行应用程序时,它似乎只是挂起(我假设失败):

_cache = new DataCache("default");

我正在运行存储模拟器并从计算模拟器调试站点。我似乎无法让网站配置为使用azure缓存。

1 个答案:

答案 0 :(得分:4)

请确保您使用的是SDK 2.1版。 缓存2.1程序包仅适用于最新版本的SDK (请参阅下面的屏幕截图)。您可以在此处查看此主题:Exception while using Windows Azure Caching : No such host is known

enter image description here