Skip to content

Commit e329b9e

Browse files
committed
Added batch process method to the pipeline
1 parent 65e1c22 commit e329b9e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pipeline.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ type Pipeliner interface {
3030
// If a certain Redis command is not yet supported, you can use Do to execute it.
3131
Do(ctx context.Context, args ...interface{}) *Cmd
3232

33-
// Process puts the commands to be executed into the pipeline buffer.
33+
// Process queues the cmd for later execution.
3434
Process(ctx context.Context, cmd Cmder) error
3535

36+
// BatchProcess adds multiple commands to be executed into the pipeline buffer.
37+
BatchProcess(ctx context.Context, cmd ...Cmder) error
38+
3639
// Discard discards all commands in the pipeline buffer that have not yet been executed.
3740
Discard()
3841

@@ -79,7 +82,12 @@ func (c *Pipeline) Do(ctx context.Context, args ...interface{}) *Cmd {
7982

8083
// Process queues the cmd for later execution.
8184
func (c *Pipeline) Process(ctx context.Context, cmd Cmder) error {
82-
c.cmds = append(c.cmds, cmd)
85+
return c.BatchProcess(ctx, cmd)
86+
}
87+
88+
// BatchProcess queues multiple cmds for later execution.
89+
func (c *Pipeline) BatchProcess(ctx context.Context, cmd ...Cmder) error {
90+
c.cmds = append(c.cmds, cmd...)
8391
return nil
8492
}
8593

0 commit comments

Comments
 (0)