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

Tweak transaction API.

This commit is contained in:
Vladimir Mihailenco
2016-05-02 15:54:15 +03:00
parent 033a4de2fb
commit 092698ecd3
8 changed files with 138 additions and 161 deletions

View File

@ -59,15 +59,13 @@ func (c *ClusterClient) getClients() map[string]*Client {
return clients
}
// Watch creates new transaction and marks the keys to be watched
// for conditional execution of a transaction.
func (c *ClusterClient) Watch(keys ...string) (*Tx, error) {
func (c *ClusterClient) Watch(fn func(*Tx) error, keys ...string) error {
addr := c.slotMasterAddr(hashtag.Slot(keys[0]))
client, err := c.getClient(addr)
if err != nil {
return nil, err
return err
}
return client.Watch(keys...)
return client.Watch(fn, keys...)
}
// PoolStats returns accumulated connection pool stats.