【问题标题】:Replacing Windows Azure Cache with Redis Cache?用 Redis 缓存替换 Windows Azure 缓存?
【发布时间】:2016-06-04 06:23:07
【问题描述】:

我目前正在使用 Windows Azure 缓存进行缓存,但是我想使用 Redis 缓存。我尝试从我的项目中删除 Windows Azure 缓存包并添加了 Redis 缓存包,并进行了适当的配置。

但是这似乎不起作用,并且给了我很多构建错误,因为我相信它仍在寻找 Windows Azure 缓存。

我将如何解决这个问题并成功切换到 Redis 缓存?

我还想知道我是否应该从我的 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>

【问题讨论】:

  • 您可能希望在您的问题中添加这些构建错误的描述。
  • 只是意料之中? Redis 并不是 Windows Azure 缓存的替代品。这些包没有实现相同的 API。
  • 错误是:“CloudServices64:Cannot find the file named 'approot\bin\Microsoft.WindowsAzure.caching\ClientPerfCounterInstaller.exe' for start task Microsoft.WindowsAzure.caching\ClientPerfCounterInstaller.exe of myprojWebRole
  • @TimLovell-Smith 那么我将如何进行更改?

标签: asp.net azure caching redis stackexchange.redis


【解决方案1】:

对于这个特定的错误: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 角色项目属性的缓存选项卡来禁用角色内缓存:

【讨论】:

    【解决方案2】:

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

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

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

    正确卸载插件和客户端库后,您应该不会再看到有关 ClientPerfCounterInstaller 的错误。

    3) 单独配置一个 Azure Redis 缓存作为您的缓存(通过门户、powershell 等),以便您可以连接到一个缓存,并使用连接字符串配置您的应用程序。

    【讨论】:

    • 谢谢你真的很有见地!我遇到的另一个问题是在我的 WebRole 的 web.config 文件中,我看到了这个标签,如果我要切换到 Redis 缓存,我应该把它取出来——我把代码放在我的描述中。
    • @chillax786 是的,您可以从 web.config 中删除整个 dataCacheClient 部分
    猜你喜欢
    • 1970-01-01
    • 2014-10-05
    • 2016-09-10
    • 2019-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 2014-07-09
    相关资源
    最近更新 更多