NAME
Async::Redis::AutoPipeline - Automatic command batching
DESCRIPTION
AutoPipeline transparently batches Redis commands issued in the same event loop tick into a single pipeline, reducing network round-trips without changing the caller's API.
How It Works
# These three commands are batched automatically
my $f1 = $redis->set('a', 1);
my $f2 = $redis->set('b', 2);
my $f3 = $redis->get('a');
await Future->needs_all($f1, $f2, $f3);
When auto_pipeline => 1:
Commands queue locally instead of sending immediately.
A next-tick flush is scheduled with
Future::IO->sleep(0).When the event loop yields, queued commands flush as a pipeline.
Responses are distributed to the original command futures.
Invariants
_flush_pendingprevents double-scheduling_flushingguard prevents reentrancyDepth limit triggers multiple batches if exceeded
Future::IO->sleep(0)provides the non-blocking yield point