1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Improve Tx example.

This commit is contained in:
Vladimir Mihailenco
2015-11-15 10:23:00 +02:00
parent d1e774fa21
commit f766eb0209
2 changed files with 26 additions and 17 deletions

View File

@ -23,6 +23,18 @@ type Multi struct {
closed bool
}
// Watch marks the keys to be watched for conditional execution
// of a transaction.
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
}
// Deprecated. Use Watch instead.
func (c *Client) Multi() *Multi {
multi := &Multi{
base: &baseClient{