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:
12
multi.go
12
multi.go
@ -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{
|
||||
|
Reference in New Issue
Block a user