Exemple #1
0
            internal override T[] Parse(RedisExecutor executor)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                long count = executor.ReadInteger(false);

                return(Read(count / this._parseItemCount, executor).ToArray());
            }
Exemple #2
0
            internal override Result Parse(RedisExecutor executor)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                var count = executor.ReadInteger(false);

                if (count != this._tranCommands.Count)
                {
                    throw new RedisProtocolException(String.Format("预期 {0} 事务返回项,实际只有 {1} 个返回项。", this._tranCommands.Count, count));
                }
                var            node   = this._tranCommands.First;
                Queue <object> values = new Queue <object>((int)count);

                try
                {
                    do
                    {
                        values.Enqueue(node.Value.ObjectParse(executor));
                        node = node.Next;
                    } while(node != null);
                }
                catch (Exception)
                {
                    this._tranCommands.Clear();
                    throw;
                }

                this._tranCommands.Each(command => command.RunCallback(values.Dequeue()));
                this._tranCommands.Clear();
                return(Result.Successfully);
            }
Exemple #3
0
        internal override RedisType Parse(RedisExecutor executor)
        {
            executor.AssertType(RedisReplyType.Status);
            var type_s = executor.ReadLine();

            return((RedisType)Enum.Parse(REDIS_TYPE, type_s, true));
        }
Exemple #4
0
 internal override T[] Parse(RedisExecutor executor)
 {
     executor.AssertType(RedisReplyType.MultiBulk);
     if (executor.ReadInteger(false) != 2)
     {
         throw new RedisProtocolException("预期返回 2 个项。");
     }
     this.Cursor = Int64.Parse(executor.ReadBulkString());
     return(base.Parse(executor));
 }
Exemple #5
0
            internal override DateTime Parse(RedisExecutor executor)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                executor.AssertSize(2);

                int timestamp    = Int32.Parse(executor.ReadBulkString());
                int microseconds = Int32.Parse(executor.ReadBulkString());

                return(FromTimestamp(timestamp, microseconds));
            }
Exemple #6
0
        internal override T Parse(RedisExecutor executor)
        {
            if (this._checkType)
            {
                executor.AssertType(RedisReplyType.MultiBulk);
                executor.AssertSize(2);
            }
            T item = (T)Activator.CreateInstance(typeof(T), true);

            item.Parse(executor);
            return(item);
        }
Exemple #7
0
        internal override BinaryValue Parse(RedisExecutor executor)
        {
            var type = executor.ReadType();

            if (type == RedisReplyType.Bulk)
            {
                var bytes = executor.ReadBulk(false);
                if (bytes == null || bytes.Length == 0)
                {
                    return(null);
                }
                return(new BinaryValue(bytes));
            }

            executor.AssertType(RedisReplyType.MultiBulk, type);
            executor.AssertSize(-1);
            return(null);
        }