예제 #1
0
 public ResponseData DoRangByScore(RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
 {
     lock (_syncLocker)
     {
         key.KeyCheck();
         RedisCoder.RequestForRandByScore(type, key, min, max, rangType, offset, count, withScore);
         var result = RedisCoder.Decoder(type);
         if (result.Type == ResponseType.Redirect)
         {
             return((ResponseData)OnRedirect.Invoke(result.Data, OperationType.DoRangByScore, type, key, min, max, rangType, offset, count, withScore));
         }
         else
         {
             return(result);
         }
     }
 }
예제 #2
0
        public ResponseData DoRangByScore(RequestType type, string key, double min = double.MinValue, double max = double.MaxValue, RangType rangType = RangType.None, long offset = -1, int count = 20, bool withScore = false)
        {
            key.KeyCheck();

            ResponseData result = new ResponseData()
            {
                Type = ResponseType.Empty, Data = "未知的命令"
            };

            try
            {
                result = TaskHelper.Run((token) =>
                {
                    lock (SyncRoot)
                    {
                        RedisCoder.RequestForRandByScore(type, key, min, max, rangType, offset, count, withScore);
                        var sresult = RedisCoder.Decoder(type, token);
                        if (sresult != null && sresult.Type == ResponseType.Redirect)
                        {
                            return((ResponseData)OnRedirect.Invoke(sresult.Data, OperationType.DoRangByScore, type, key, min, max, rangType, offset, count, withScore));
                        }
                        else
                        {
                            return(sresult);
                        }
                    }
                }, _actionTimeout).Result;
            }
            catch (TaskCanceledException tex)
            {
                result.Type = ResponseType.Error;
                result.Data = "Action Timeout";
            }
            catch (Exception ex)
            {
                result.Type = ResponseType.Error;
                result.Data = ex.Message;
            }
            return(result);
        }