Skip to content

Feature: Batch processing cmds in pipeline #3503

@RasankRam

Description

@RasankRam

Hello everyone.
Thank you very much for adding Cmds() - the ability to retrieve cmds currently in the pipeline.
I'm wondering, are there any plans to support adding multiple commands at once ? At the moment it's only possible to add a single cmd to the pipeline.

Right now our code looks like this:

for _, cmd := range redisPipe.Cmds() {
    txw.parentTx.redisPipe.Process(cmd)
}

So essentially we're just iterating over each value in the loop, while inside .Process it's simply appending the element to a slice:

func (c *Pipeline) Process(ctx context.Context, cmd Cmder) error {
    c.cmds = append(c.cmds, cmd)
    return nil
}

This naturally raises the question - would it be possible to provide a new method for the Pipeline structure, for example, ProcessBatch:

func (c *Pipeline) ProcessBatch(ctx context.Context, cmds ...Cmder) error {
    c.cmds = append(c.cmds, cmds...)
    return nil
}

Or, perhaps in some major version, consider replacing the cmd Cmder param in the Process method with a variadic version ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions