1
0
mirror of https://github.com/redis/go-redis.git synced 2025-12-03 18:31:14 +03:00

autopipeline playground

This commit is contained in:
Nedyalko Dyakov
2025-10-27 16:08:40 +02:00
parent 9f3f8b7c7b
commit 7198f47baa
17 changed files with 1806 additions and 7 deletions

View File

@@ -1175,6 +1175,28 @@ func (c *Client) TxPipeline() Pipeliner {
return &pipe
}
// AutoPipeline creates a new autopipeliner that automatically batches commands.
// Commands are automatically flushed based on batch size and time interval.
// The autopipeliner must be closed when done to flush pending commands.
//
// Example:
//
// ap := client.AutoPipeline()
// defer ap.Close()
//
// for i := 0; i < 1000; i++ {
// ap.Do(ctx, "SET", fmt.Sprintf("key%d", i), i)
// }
//
// Note: AutoPipeline requires AutoPipelineConfig to be set in Options.
// If not set, this will panic.
func (c *Client) AutoPipeline() *AutoPipeliner {
if c.opt.AutoPipelineConfig == nil {
c.opt.AutoPipelineConfig = DefaultAutoPipelineConfig()
}
return NewAutoPipeliner(c, c.opt.AutoPipelineConfig)
}
func (c *Client) pubSub() *PubSub {
pubsub := &PubSub{
opt: c.opt,