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

cluster: add Watch support.

This commit is contained in:
Vladimir Mihailenco
2015-12-16 16:11:52 +02:00
parent 745d73395e
commit 9079a66323
5 changed files with 103 additions and 25 deletions

View File

@ -44,6 +44,17 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
return client
}
// Watch creates new transaction and marks the keys to be watched
// for conditional execution of a transaction.
func (c *ClusterClient) Watch(keys ...string) (*Multi, error) {
addr := c.slotMasterAddr(hashSlot(keys[0]))
client, err := c.getClient(addr)
if err != nil {
return nil, err
}
return client.Watch(keys...)
}
// Close closes the cluster client, releasing any open resources.
//
// It is rare to Close a ClusterClient, as the ClusterClient is meant