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

refactor: remove unused context attributes (#2154)

* refactor: remove unused context field
This commit is contained in:
Knut Zuidema
2022-07-14 12:43:42 +02:00
committed by GitHub
parent 092a692384
commit e061db8c13
5 changed files with 16 additions and 25 deletions

6
tx.go
View File

@ -20,17 +20,15 @@ type Tx struct {
cmdable
statefulCmdable
hooks
ctx context.Context
}
func (c *Client) newTx(ctx context.Context) *Tx {
func (c *Client) newTx() *Tx {
tx := Tx{
baseClient: baseClient{
opt: c.opt,
connPool: pool.NewStickyConnPool(c.connPool),
},
hooks: c.hooks.clone(),
ctx: ctx,
}
tx.init()
return &tx
@ -50,7 +48,7 @@ func (c *Tx) Process(ctx context.Context, cmd Cmder) error {
//
// The transaction is automatically closed when fn exits.
func (c *Client) Watch(ctx context.Context, fn func(*Tx) error, keys ...string) error {
tx := c.newTx(ctx)
tx := c.newTx()
defer tx.Close(ctx)
if len(keys) > 0 {
if err := tx.Watch(ctx, keys...).Err(); err != nil {