Beispiel #1
0
        private void ParseMultiBulkReply(RedisResponseBuffer buffer, string line)
        {
            if (!int.TryParse(line, out int count))
            {
                throw new InvalidDataException($"Expected Multi Bulk Reply to indicate result count. Received \"{line}\"");
            }

            for (int index = 0; index < count; index++)
            {
                var multiline = ParseLine(out char marker);
                if (!marker.Equals(':') && !marker.Equals('$') && !marker.Equals('*'))
                {
                    buffer.PushEmpty(index);
                    continue;
                }

                if (marker.Equals(':'))
                {
                    buffer.Push(index, multiline);
                    continue;
                }

                if (marker.Equals('*'))
                {
                    ParseMultiBulkReply(buffer, multiline);
                    continue;
                }

                if (!int.TryParse(multiline, out int length) || length.Equals(-1))
                {
                    buffer.PushEmpty(index);
                }
                else
                {
                    buffer.Push(index, ParseLine(length));
                }
            }
        }
Beispiel #2
0
        private void ParseBulkReply(RedisResponseBuffer buffer, string line)
        {
            if (!int.TryParse(line, out int length))
            {
                throw new InvalidDataException($"Expected Bulk Reply to indicate stream length. Received \"{line}\"");
            }

            if (length.Equals(-1))
            {
                buffer.PushEmpty();
            }
            else
            {
                buffer.Push(ParseLine(length));
            }
        }