Close closes the transaction, releasing any open resources.
(ctx context.Context)
| 89 | |
| 90 | // Close closes the transaction, releasing any open resources. |
| 91 | func (c *Tx) Close(ctx context.Context) error { |
| 92 | // UNWATCH is only needed while a WATCH is still active. EXEC discards the |
| 93 | // watched keys server-side on both commit and abort, so the common |
| 94 | // WATCH/.../EXEC paths leave nothing to release and avoid the extra round |
| 95 | // trip. |
| 96 | if c.watchArmed { |
| 97 | _ = c.Unwatch(ctx).Err() |
| 98 | } |
| 99 | return c.baseClient.Close() |
| 100 | } |
| 101 | |
| 102 | // Watch marks the keys to be watched for conditional execution |
| 103 | // of a transaction. |