NAME

Async::Redis::Iterator - Cursor-based SCAN iterator

SYNOPSIS

my $iter = $redis->scan_iter(match => 'user:*', count => 100);

while (my $batch = await $iter->next) {
    for my $key (@$batch) {
        say $key;
    }
}

DESCRIPTION

Iterator provides async cursor-based iteration over Redis SCAN commands:

  • SCAN - iterate keys

  • HSCAN - iterate hash field/value pairs

  • SSCAN - iterate set members

  • ZSCAN - iterate sorted set members and scores as a flat list

METHODS

next

my $batch = await $iter->next;

Return the next batch as an arrayref, or undef when the scan is complete and there are no elements in the final batch. Redis may return empty intermediate batches; those are returned as empty arrayrefs and are still truthy in Perl.

reset

$iter->reset;

Reset the cursor to zero so iteration can start again.

cursor

Return the current Redis cursor.

done

Return true after Redis has returned cursor 0.

BEHAVIOR

  • Returns batches of elements, not individual items

  • Cursor managed internally

  • next returns undef when iteration is complete

  • Safe during key modifications, but Redis may return duplicates or miss keys

  • count is a hint, not a guarantee