public override object[] Parse(RedisReader reader) { if (_parsers.Count == 0) { return(reader.ReadMultiBulk(bulkAsString: true)); } reader.ExpectType(RedisMessage.MultiBulk); long count = reader.ReadInt(false); if (count != _parsers.Count) { throw new RedisProtocolException(String.Format("Expecting {0} array items; got {1}", _parsers.Count, count)); } object[] results = new object[_parsers.Count]; for (int i = 0; i < results.Length; i++) { results[i] = _parsers.Dequeue()(reader); } return(results); }
public override RedisRole Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); int count = (int)reader.ReadInt(false); string role = reader.ReadBulkString(); switch (role) { case "master": return(ParseMaster(count, role, reader)); case "slave": return(ParseSlave(count, role, reader)); case "sentinel": return(ParseSentinel(count, role, reader)); default: throw new RedisProtocolException("Unexpected role: " + role); } }
object[] ReadTransaction(Stream input) { if (!_captureResults) { RedisObjects command = RedisCommand.Exec(); command.Parser(input); return(null); } RedisReader.ExpectType(input, RedisMessage.MultiBulk); long count = RedisReader.ReadInt(input, false); if (count == -1) { return(null); } object[] output = new object[_parsers.Count]; for (int i = 0; i < output.Length; i++) { output[i] = _connection.Read(_parsers.Dequeue()); } return(output); }
public override Tuple <string, string> Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); reader.ExpectSize(2); return(Tuple.Create(reader.ReadBulkString(), reader.ReadBulkString())); }
public void Read(Stream destination, int bufferSize) { _reader.ExpectType(RedisMessage.Bulk); _reader.ReadBulk(destination, bufferSize, false); }