AWS ElastiCacheRedis间歇性异常在xxxxxxxx.yyyyyyyyy.clustercfg.apse2.cache.amazonaws.com:6379

问题描述

我正在运行一个C#.NET Core程序,该程序使用ServiceStack.Redis库与AWS ElastiCache中的REdis实现进行接口。 99%的情况下,它运行良好,但是间歇性地出现以下错误,并且依赖于缓存中GetValue的方法失败:

No master found in xxxxxxxx.yyyyyyyyy.clustercfg.apse2.cache.amazonaws.com:6379

关于此错误,我几乎找不到任何信息。我正在使用:

  • .NET Core 3.1
  • ServiceStack.Redis.Core 5.9.2

我在AWS中的Redis配置为:

  • 引擎版本:5.0.6
  • 碎片:1
  • 节点数:2个节点

我如何实例化客户端并使用它来获取缓存项的示例:

    private readonly RedisManagerPool _redisClient;

    _redisClient = new RedisManagerPool(Environment.GetEnvironmentvariable("CACHE_URL") + ":" +
            Environment.GetEnvironmentvariable("CACHE_PORT"));

        public static T GetCacheValue<T>(string cacheKey,RedisManagerPool pool)
        {
            try
            {
                using (var client = pool.GetClient())
                {
                    client.RetryCount = Convert.ToInt32(Environment.GetEnvironmentvariable("CACHE_RETRY_COUNT"));
                    client.RetryTimeout = Convert.ToInt32(Environment.GetEnvironmentvariable("CACHE_RETRY_TIMEOUT"));
                    var cacheValue = client.Get<T>(cacheKey);
                    return cacheValue;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)