NAME
DBIx::Class::Async::Storage::DBI::Cursor - Asynchronous cursor for DBIx::Class ResultSets using Futures
VERSION
Version 0.41
SYNOPSIS
my $cursor = DBIx::Class::Async::Storage::DBI::Cursor->new(
storage => $storage,
rs => $resultset,
);
$cursor->next->then(sub {
my ($row) = @_;
return unless $row;
say $row->id;
});
# Reset and iterate again
$cursor->reset;
DESCRIPTION
This module implements an asynchronous cursor abstraction for DBIx::Class ResultSets backed by DBI storage.
It fetches rows from a ResultSet incrementally in fixed-size batches (pages) and exposes a next method that returns a Future. Each call to next resolves to a single row object or undef when the result set has been exhausted.
The cursor maintains an internal buffer and transparently issues paginated queries using the ResultSet's page and rows attributes.
This class is primarily intended for use by asynchronous storage layers or consumers that wish to process large result sets without loading all rows into memory at once.
CONSTRUCTOR
new
my $cursor = DBIx::Class::Async::Storage::DBI::Cursor->new(%args);
Creates a new asynchronous cursor.
Arguments
storageThe storage object associated with the ResultSet. This value is currently stored but not actively used by the cursor.
rsA DBIx::Class::ResultSet to iterate over. If the ResultSet has a
rowsattribute set, it will be used as the batch size for pagination.
Batch Size
The cursor fetches rows in batches. The batch size is determined as follows:
If the ResultSet has
$rs->{_attrs}{rows}defined, that value is usedOtherwise, a default batch size of 20 rows is used
METHODS
reset
$cursor->reset;
Resets the cursor to the beginning of the ResultSet.
This clears the internal buffer, resets the page counter to 1, and marks the cursor as not finished.
The cursor may then be iterated again from the start.
Returns the cursor itself.
INTERNAL STATE
The cursor maintains the following internal state:
bufferAn array reference holding prefetched rows.
pageThe current page number used for pagination.
finishedBoolean flag indicating whether the result set has been exhausted.
batchThe number of rows fetched per page.
These attributes are considered internal implementation details and are not part of the public API.
next
my $future = $cursor->next;
Returns a Future that resolves to the next row in the ResultSet.
Behaviour
If buffered rows are available, the Future resolves immediately
If the buffer is empty, the next page of rows is fetched asynchronously
If no more rows are available, the Future resolves to
undef
Each resolved value is a single row object (typically a DBIx::Class::Row), or undef when iteration is complete.
This method never throws synchronously; all results are delivered via the returned Future.
LIMITATIONS
Requires a ResultSet that supports paging via
pageandrowsAssumes that
$rs->search(...)->allreturns a FutureNot thread-safe
SEE ALSO
AUTHOR
Mohammad Sajid Anwar, <mohammad.anwar at yahoo.com>
REPOSITORY
https://github.com/manwar/DBIx-Class-Async
BUGS
Please report any bugs or feature requests through the web interface at https://github.com/manwar/DBIx-Class-Async/issues. I will be notified and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc DBIx::Class::Async::Storage::DBI::Cursor
You can also look for information at:
BUG Report
CPAN Ratings
Search MetaCPAN
LICENSE AND COPYRIGHT
Copyright (C) 2026 Mohammad Sajid Anwar.
This program is free software; you can redistribute it and / or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License.By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you,you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement,then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.