mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
redis: Rename mtx to reqsMtx.
This commit is contained in:
18
pipeline.go
18
pipeline.go
@ -22,7 +22,9 @@ func (c *Client) Pipelined(do func(*PipelineClient)) ([]Req, error) {
|
||||
return nil, err
|
||||
}
|
||||
defer pc.Close()
|
||||
|
||||
do(pc)
|
||||
|
||||
return pc.RunQueued()
|
||||
}
|
||||
|
||||
@ -31,20 +33,20 @@ func (c *PipelineClient) Close() error {
|
||||
}
|
||||
|
||||
func (c *PipelineClient) DiscardQueued() {
|
||||
c.mtx.Lock()
|
||||
c.reqsMtx.Lock()
|
||||
c.reqs = c.reqs[:0]
|
||||
c.mtx.Unlock()
|
||||
c.reqsMtx.Unlock()
|
||||
}
|
||||
|
||||
func (c *PipelineClient) RunQueued() ([]Req, error) {
|
||||
c.mtx.Lock()
|
||||
if len(c.reqs) == 0 {
|
||||
c.mtx.Unlock()
|
||||
return c.reqs, nil
|
||||
}
|
||||
c.reqsMtx.Lock()
|
||||
reqs := c.reqs
|
||||
c.reqs = make([]Req, 0)
|
||||
c.mtx.Unlock()
|
||||
c.reqsMtx.Unlock()
|
||||
|
||||
if len(reqs) == 0 {
|
||||
return []Req{}, nil
|
||||
}
|
||||
|
||||
conn, err := c.conn()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user