func (c *Multi) Exec(f func() error) ([]Cmder, error) {
	if c.closed {
		return nil, errClosed
	}
	c.cmds = []Cmder{NewStatusCmd("MULTI")}
	if err := f(); err != nil {
		return nil, err
	}
	c.cmds = append(c.cmds, NewSliceCmd("EXEC"))
	cmds := c.cmds
	c.cmds = nil
	if len(cmds) == 2 {
		return []Cmder{}, nil
	}
	retCmds := cmds[1 : len(cmds)-1]
	cn, _, err := c.base.conn()
	if err != nil {
		setCmdsErr(retCmds, err)
		return retCmds, err
	}
	err = c.execCmds(cn, cmds)
	c.putConn(cn, err)
	return retCmds, err
}
Exec executes all previously queued commands in a transaction
and restores the connection state to normal.

When using WATCH, EXEC will execute commands only if the watched keys
were not modified, allowing for a check-and-set mechanism.

Exec always returns list of commands. If transaction fails
TxFailedErr is returned. Otherwise Exec returns error of the first
failed command or nil.
package redis
import (
	"errors"
	"fmt"
	"log"
)
var errDiscard = errors.New("redis: Discard can be used only inside Exec")
type Multi struct {
	commandable
	base *baseClient
	cmds   []Cmder
	closed bool
}
func (c *Client) Watch(keys ...string) (*Multi, error) {
	tx := c.Multi()
	if err := tx.Watch(keys...).Err(); err != nil {
		tx.Close()
		return nil, err
	}
	return tx, nil
}
func (c *Client) Multi() *Multi {
	multi := &Multi{
		base: &baseClient{
			opt:      c.opt,
			connPool: newStickyConnPool(c.connPool, true),
		},
	}
	multi.commandable.process = multi.process
	return multi
}
func (c *Multi) putConn(cn *conn, err error) {
	if isBadConn(cn, err) {
		c.base.connPool.(*stickyConnPool).Reset(err)
	} else {
		err := c.base.connPool.Put(cn)
		if err != nil {
			log.Printf("redis: putConn failed: %s", err)
		}
	}
}
func (c *Multi) process(cmd Cmder) {
	if c.cmds == nil {
		c.base.process(cmd)
	} else {
		c.cmds = append(c.cmds, cmd)
	}
}
func (c *Multi) Close() error {
	c.closed = true
	if err := c.Unwatch().Err(); err != nil {
		log.Printf("redis: Unwatch failed: %s", err)
	}
	return c.base.Close()
}
func (c *Multi) Watch(keys ...string) *StatusCmd {
	args := make([]interface{}, 1+len(keys))
	args[0] = "WATCH"
	for i, key := range keys {
		args[1+i] = key
	}
	cmd := NewStatusCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *Multi) Unwatch(keys ...string) *StatusCmd {
	args := make([]interface{}, 1+len(keys))
	args[0] = "UNWATCH"
	for i, key := range keys {
		args[1+i] = key
	}
	cmd := NewStatusCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *Multi) Discard() error {
	if c.cmds == nil {
		return errDiscard
	}
	c.cmds = c.cmds[:1]
	return nil
}