1

最近,我们从 Azure 角色缓存转移到了 Azure Redis 缓存(由 Azure 网站使用)。

我现在正在审查代码,一行代码引起了我的注意。

using Microsoft.Practices.TransientFaultHandling;

// CODE

_retryPolicy = new RetryPolicy<CacheTransientErrorDetectionStrategy>(retryStrategy);

// CODE

_retryPolicy.ExecuteAction(() => dataCache.StringGet(fullCacheKey));

TransientFaultHandling 程序集中的 RetryPolicy 对 Redis 缓存有意义吗?或者当我们使用 Azure Redis 而不是 In-Role 缓存时,这是一个实际上没有任何用途的代码?

4

2 回答 2

1

您怀疑它是正确的,它CacheTransientErrorDetectionStrategy是专门为 Windows Azure 缓存而构建的。

http://www.projky.com/entlib/6.0/Microsoft/Practices/EnterpriseLibrary/TransientFaultHandling/CacheTransientErrorDetectionStrategy.cs.html

/// <summary>
/// Provides the transient error detection logic that can recognize transient faults when dealing with Windows Azure Caching.
/// </summary>

您可以保留 RetryPolicy 但您需要用您自己的实现替换错误检测策略ITransientErrorDetectionStrategy,例如检测超时异常。

于 2015-04-16T12:18:15.857 回答
0

这是对的。您可以重用 RetryPolicy 逻辑

于 2015-04-16T00:29:27.083 回答