NAME

Async::Redis::Pipeline - Command pipelining

SYNOPSIS

my $pipe = $redis->pipeline;
$pipe->set('key1', 'value1');
$pipe->set('key2', 'value2');
$pipe->get('key1');

my $results = await $pipe->execute;
# $results = ['OK', 'OK', 'value1']

# Or chained style:
my $results = await $redis->pipeline
    ->set('a', 1)
    ->get('a')
    ->execute;

DESCRIPTION

Pipeline collects multiple Redis commands and executes them in a single network round-trip, significantly reducing latency for bulk operations.

Error Handling

Two distinct failure modes:

1. **Command-level Redis errors** (WRONGTYPE, OOM): Captured inline in result array. Pipeline continues. Check each slot for Error objects.

2. **Transport failures** (connection loss, timeout): Entire pipeline fails. Cannot determine which commands succeeded.

METHODS

new

my $pipe = Async::Redis::Pipeline->new(
    redis     => $redis_client,
    max_depth => 10000,
);

Create a new pipeline. Usually called via $redis->pipeline.

command

$pipe->command('SET', 'key', 'value');

Queue a command explicitly.

AUTOLOAD

Any Redis command can be called directly:

$pipe->set('key', 'value');
$pipe->hset('hash', 'field', 'value');
$pipe->lpush('list', 'item');

execute

my $results = await $pipe->execute;

Execute all queued commands and return results array.

count

my $n = $pipe->count;

Return number of queued commands.