2016-02-22 114 views
-1

我目前使用Windows Azure缓存进行缓存,但是我想使用Redis缓存。我尝试从我的项目中删除Windows Azure缓存软件包,并添加了Redis缓存软件包,并进行了相应的配置。用Redis缓存替换Windows Azure缓存?

但是,这似乎并没有工作,并给了我很多构建错误,因为我相信它仍然在寻找Windows Azure缓存。

我该如何解决这个问题并成功切换到Redis Cache?

另外想知道是否应该从我的WebRole的Web.config文件中删除此部分?

<dataCacheClients> 
    <dataCacheClient name="default"> 

    <!--To use the Windows Azure Cache Service, set identifier to be the endpoint of the cache cluster --> 
    <autoDiscover isEnabled="true" identifier="testingabc.cache.windows.net" /> 
    <!--<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="true"> 
    <messageSecurity authorizationInfo="MyAuthInfo" /> 
    </securityProperties> 
</dataCacheClient> 

+0

您可能希望在您的问题中添加这些构建错误的描述。 –

+0

只有预料? Redis并不代替Windows Azure Cache。这些软件包不实现相同的API。 –

+0

错误是:“CloudServices64:找不到名为'approot \ bin \ Microsoft.WindowsAzure.caching \ ClientPerfCounterInstaller.exe'启动任务myprojWebRole的Microsoft.WindowsAzure.caching \ ClientPerfCounterInstaller.exe – chillax786

回答

0

对于这个特殊的错误:The Error is: "CloudServices64:Cannot find the file named 'approot\bin\Microsoft.WindowsAzure.caching\ClientPerfCounterInstaller.exe' for startup task Microsoft.WindowsAzure.caching\ClientPerfCounterInstaller.exe of myprojWebRole,请尝试进入您的Web角色项目的属性的缓存选项卡中禁用的角色缓存:

enter image description here

0

你可能不了解一些切换到redis所需的内容。您正在使用的旧Windows Azure缓存解决方案通过将缓存作为Windows Azure“插件”运行在您的工作/ Web角色上而工作。 (然后使用Azure Caching客户端库访问该缓存。)没有用于redis的等效插件。要切换到redis,您需要:

1)停止使用Azure缓存客户端库并切换到例如StackExchange.Redis作为客户端库 - 无论您使用的是redis库,它都是完全不同的API,您需要更改执行缓存操作的C#代码。

2)关闭插件(这是“启用缓存”复选框),并从您的角色定义中删除任何相关的启动任务/工件。然后,您将不再在您的web/worker角色的本地运行缓存。

一旦您正确地卸载了插件和客户端库,您将不会再看到有关ClientPerfCounterInstaller的错误。

3)单独配置一个Azure Redis缓存作为您的缓存(通过portal,powershell等),以便您有缓存连接,并使用连接字符串配置您的应用。

+0

谢谢你真的很有洞察力!我的另一个问题是我的web.config文件中的WebRole我看到这个标签,如果我切换到Redis Cache,我应该把它拿出来吗?我把代码放在我的描述中 – chillax786

+0

@ chillax786是的你可以从web.config中删除整个dataCacheClient部分 –