最近,我们从 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 而不是角色内缓存时,这段代码实际上不再有任何用途?
最佳答案
您的怀疑是正确的,CacheTransientErrorDetectionStrategy
是专门为 Windows Azure 缓存构建的。
/// <summary>
/// Provides the transient error detection logic that can recognize transient faults when dealing with Windows Azure Caching.
/// </summary>
您可以保留 RetryPolicy,但需要将错误检测策略替换为您自己的 ITransientErrorDetectionStrategy
实现,例如检测超时异常。
关于c# - 使用 Azure Redis 缓存重试策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29661763/