static Tuple <T1, T2> Create(RedisReader reader) { T1 item1 = (T1)converter1.Value.ConvertFromInvariantString(reader.ReadBulkString()); T2 item2 = (T2)converter2.Value.ConvertFromInvariantString(reader.ReadBulkString()); return(Tuple.Create(item1, item2)); }
public override DateTimeOffset Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); reader.ExpectSize(2); int timestamp = Int32.Parse(reader.ReadBulkString()); int microseconds = Int32.Parse(reader.ReadBulkString()); return(FromTimestamp(timestamp, microseconds)); }
static RedisSlaveRole ParseSlave(int num, string role, RedisReader reader) { reader.ExpectSize(5, num); string master_ip = reader.ReadBulkString(); int port = (int)reader.ReadInt(); string state = reader.ReadBulkString(); long data = reader.ReadInt(); return(new RedisSlaveRole(role, master_ip, port, state, data)); }
public override Tuple <string, string> Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); long count = reader.ReadInt(false); if (count != 2) { throw new RedisProtocolException("Expected 2 items"); } return(Tuple.Create(reader.ReadBulkString(), reader.ReadBulkString())); }
public override Tuple <string, string> Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); long count = reader.ReadInt(false); if (count != 2) { return(null); //使用 BLPop 命令在 RedisArray.cs 中报错的解决办法。 #22 } //reader.ExpectSize(2); return(Tuple.Create(reader.ReadBulkString(), reader.ReadBulkString())); }
static RedisSubscriptionMessage ParseMessage(string type, RedisReader reader) { if (type == "message") { return(new RedisSubscriptionMessage(type, reader.ReadBulkString(), reader.ReadBulkString())); } else if (type == "pmessage") { return(new RedisSubscriptionMessage(type, reader.ReadBulkString(), reader.ReadBulkString(), reader.ReadBulkString())); } throw new RedisProtocolException("Unexpected type " + type); }
static RedisSubscriptionChannel ParseChannel(string type, RedisReader reader) { switch (type) { case "subscribe": case "unsubscribe": return(new RedisSubscriptionChannel(type, reader.ReadBulkString(), null, reader.ReadInt())); case "psubscribe": case "punsubscribe": return(new RedisSubscriptionChannel(type, null, reader.ReadBulkString(), reader.ReadInt())); } throw new RedisProtocolException("Unexpected type " + type); }
public override string Parse(RedisReader reader) { if (IsNullable) { RedisMessage type = reader.ReadType(); if (type == RedisMessage.Bulk) { return(reader.ReadBulkString(false)); } reader.ReadMultiBulk(false); return(null); } else { return(reader.ReadBulkString()); } }
public override double?Parse(RedisReader reader) { string result = reader.ReadBulkString(); if (result == null) { return(null); } return(RedisFloat.FromString(result)); }
static RedisMasterRole ParseMaster(int num, string role, RedisReader reader) { reader.ExpectSize(3, num); long offset = reader.ReadInt(); reader.ExpectType(RedisMessage.MultiBulk); var slaves = new Tuple <string, int, int> [reader.ReadInt(false)]; for (int i = 0; i < slaves.Length; i++) { reader.ExpectType(RedisMessage.MultiBulk); reader.ExpectSize(3); string ip = reader.ReadBulkString(); int port = Int32.Parse(reader.ReadBulkString()); int slave_offset = Int32.Parse(reader.ReadBulkString()); slaves[i] = new Tuple <string, int, int>(ip, port, slave_offset); } return(new RedisMasterRole(role, offset, slaves)); }
private static double?ParseStream(Stream stream) { string result = RedisReader.ReadBulkString(stream); if (result == null) { return(null); } return(Double.Parse(result, NumberStyles.Float)); }
public override decimal?Parse(RedisReader reader) { string result = reader.ReadBulkString(); if (string.IsNullOrEmpty(result)) { return(null); } return(RedisFloat.FromString(result)); }
public override double?Parse(RedisReader reader) { string result = reader.ReadBulkString(); if (result == null) { return(null); } return(double.Parse(result, NumberStyles.Float, CultureInfo.InvariantCulture)); }
public override RedisMasterState Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); reader.ExpectSize(3); long down_state = reader.ReadInt(); string leader = reader.ReadBulkString(); long vote_epoch = reader.ReadInt(); return(new RedisMasterState(down_state, leader, vote_epoch)); }
static RedisSentinelRole ParseSentinel(int num, string role, RedisReader reader) { reader.ExpectSize(2, num); reader.ExpectType(RedisMessage.MultiBulk); string[] masters = new string[reader.ReadInt(false)]; for (int i = 0; i < masters.Length; i++) { masters[i] = reader.ReadBulkString(); } return(new RedisSentinelRole(role, masters)); }
public override long?Parse(RedisReader reader) { RedisMessage type = reader.ReadType(); if (type == RedisMessage.Int) { return(reader.ReadInt(false)); } reader.ReadBulkString(false); return(null); }
static Dictionary <string, string> ToDict(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); long count = reader.ReadInt(false); var dict = new Dictionary <string, string>(); string key = String.Empty; for (int i = 0; i < count; i++) { if (i % 2 == 0) { key = reader.ReadBulkString(); } else { dict[key] = reader.ReadBulkString(); } } return(dict); }
private static string Read(Stream stream) { var type = RedisReader.ReadType(stream); if (type == RedisMessage.Bulk) { return(RedisReader.ReadBulkString(stream, false)); } RedisReader.ReadMultiBulk(stream, false); return(null); }
private static long?ParseStream(Stream stream) { RedisMessage type = RedisReader.ReadType(stream); if (type == RedisMessage.Int) { return(RedisReader.ReadInt(stream, false)); } RedisReader.ReadBulkString(stream, false); return(null); }
public override RedisScan <T> Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); if (reader.ReadInt(false) != 2) { throw new RedisProtocolException("Expected 2 items"); } long cursor = Int64.Parse(reader.ReadBulkString()); T[] items = _command.Parse(reader); return(new RedisScan <T>(cursor, items)); }
public override RedisSlowLogEntry Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); reader.ExpectSize(4); long id = reader.ReadInt(); long timestamp = reader.ReadInt(); long microseconds = reader.ReadInt(); reader.ExpectType(RedisMessage.MultiBulk); string[] arguments = new string[reader.ReadInt(false)]; for (int i = 0; i < arguments.Length; i++) { arguments[i] = reader.ReadBulkString(); } return(new RedisSlowLogEntry(id, RedisDate.FromTimestamp(timestamp), RedisDate.Micro.FromMicroseconds(microseconds), arguments)); }
public override RedisSubscriptionResponse Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); long count = reader.ReadInt(false); string type = reader.ReadBulkString(); switch (type) { case "subscribe": case "unsubscribe": case "psubscribe": case "punsubscribe": return(ParseChannel(type, reader)); case "message": case "pmessage": return(ParseMessage(type, reader)); } throw new RedisProtocolException("Unexpected type " + type); }
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); } }
public override double Parse(RedisReader reader) { return(FromString(reader.ReadBulkString())); }
public override string Parse(RedisReader reader) { return(reader.ReadBulkString()); }
public override int Parse(RedisReader reader) { return(Int32.Parse(reader.ReadBulkString())); }
private static double ParseStream(Stream stream) { return(Double.Parse(RedisReader.ReadBulkString(stream), NumberStyles.Float)); }
public override T Parse(RedisReader reader) { return((T)converter.Value.ConvertFromInvariantString(reader.ReadBulkString())); }
public override Tuple <string, string> Parse(RedisReader reader) { reader.ExpectType(RedisMessage.MultiBulk); reader.ExpectSize(2); return(Tuple.Create(reader.ReadBulkString(), reader.ReadBulkString())); }