コード例 #1
0
        /// <summary>
        /// Get Read Only Client
        /// </summary>
        /// <returns></returns>
        public static IRedisClient GetReadOnlyClient()
        {
            if (IsSentinelMode)
            {
                var client = Rcm.GetReadOnlyClient();
                if (string.IsNullOrEmpty(SentinelNodePwd))
                {
                    client.Password = SentinelNodePwd;
                }

                if (IsKeepAliveMode)
                {
                    int count = 0;
                    while (count <= MaxAllowReGetClient)
                    {
                        if (KeepAliveService.Instance.IsAvaiable(client))
                        {
                            break;
                        }
                        else
                        {
                            client.Dispose();
                            client = null;
                            client = Rcm.GetReadOnlyClient();

                            count++;
                        }
                    }
                }

                return(client);
            }
            else
            {
                IRedisClient client = Prcm.GetReadOnlyClient();

                if (IsKeepAliveMode)
                {
                    int count = 0;
                    while (count <= MaxAllowReGetClient)
                    {
                        if (KeepAliveService.Instance.IsAvaiable(client))
                        {
                            break;
                        }
                        else
                        {
                            client.Dispose();
                            client = null;
                            client = Prcm.GetReadOnlyClient();

                            count++;
                        }
                    }
                }

                return(client);
            }
        }
コード例 #2
0
 /// <summary>
 /// Get Client
 /// </summary>
 /// <returns></returns>
 public static IRedisClient GetClient()
 {
     if (IsSentinelMode)
     {
         return(Rcm.GetReadOnlyClient());
     }
     else
     {
         return(Prcm.GetClient());
     }
 }