Exemplo n.º 1
0
func doCommand(c *redisconn.Conn, cmd string, args ...interface{}) (*parser.Resp, error) {
	writeCommand(c, cmd, args...)
	if err := c.Flush(); err != nil {
		return nil, errors.Trace(err)
	}

	resp, err := parser.Parse(c.BufioReader())
	if err != nil {
		return nil, errors.Trace(err)
	}
	return resp, nil
}
Exemplo n.º 2
0
func writeMigrateKeyCmd(c *redisconn.Conn, addr string, timeoutMs int, keys ...[]byte) error {
	hostPort := strings.Split(addr, ":")
	if len(hostPort) != 2 {
		return errors.Errorf("invalid address " + addr)
	}

	for _, key := range keys {
		err := writeCommand(c, "SLOTSMGRTTAGONE", hostPort[0], hostPort[1], int(timeoutMs), key)
		if err != nil {
			return errors.Trace(err)
		}
	}

	return errors.Trace(c.Flush())
}