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));
        }
        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));
        }
Example #3
0
            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));
            }
Example #4
0
        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));
 }
Example #6
0
        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));
        }
Example #7
0
 public override Tuple <string, string> Parse(RedisReader reader)
 {
     reader.ExpectType(RedisMessage.MultiBulk);
     reader.ExpectSize(2);
     return(Tuple.Create(reader.ReadBulkString(), reader.ReadBulkString()));
 }