internal override async ValueTask <int> Process()
        {
            var line = await ReadLine();

            if (line.ItemAt(0) != ByteConstants.Colon)
            {
                var stringLine = line.AsStringWithoutLineTerminators();
                PipeReader.AdvanceTo(line.End);

                if (line.ItemAt(0) == ByteConstants.Dash)
                {
                    throw new RedisFailedCommandException(stringLine, LastCommand);
                }

                throw new UnexpectedRedisResponseException(stringLine);
            }

            var number = SpanNumberParser.Parse(line);

            PipeReader.AdvanceTo(line.End);

            if (number == -1)
            {
                return(-1);
            }

            return((int)number);
        }
示例#2
0
        internal override async ValueTask <IEnumerable <StringRedisValue> > Process()
        {
            var line = await ReadLine();

            if (line.ItemAt(0) != ByteConstants.Asterix)
            {
                var stringLine = line.AsStringWithoutLineTerminators();
                PipeReader.AdvanceTo(line.End);
                throw new UnexpectedRedisResponseException(stringLine);
            }

            var count = SpanNumberParser.Parse(line);

            PipeReader.AdvanceTo(line.End);

            var results = new byte [count][];

            for (var i = 0; i < count; i++)
            {
                results[i] = (await ReadData()).ToArray();
            }

            return(results.ToRedisValues());
        }