NAME
Fey::Object::Iterator::Caching - A caching subclass of Fey::Object::Iterator
SYNOPSIS
use Fey::Object::Iterator::Caching;
my $iter =
Fey::Object::Iterator::Caching->new
( classes => 'MyApp::User',
handle => $sth,
bind_params => \@bind,
);
print $iter->index(); # 0
while ( my $user = $iter->next() )
{
print $iter->index(); # 1, 2, 3, ...
print $user->username();
}
# will return cached objects now
$iter->reset();
DESCRIPTION
This class implements a caching subclass of Fey::Objcet::Iterator
. This means that it caches objects it creates internally. When $iterator->reset()
is called it will re-use those objects before fetching more data from the DBMS.
METHODS
This class provides the following methods:
$iterator->next()
This returns the next set of objects. If it has a cached set of objects for the appropriate index, it returns them instead of fetching more data from the DBMS. Otherwise it is identical to calling next()
on a Fey::Object::Iterator
object.
$iterator->reset()
Resets the iterator so that the next call to $iterator->next()
returns the first objects. Internally, this does not reset the DBI
statement handle, it simply makes the iterator use cached objects.
AUTHOR
Dave Rolsky, <autarch@urth.org>
BUGS
See Fey::ORM for details.
COPYRIGHT & LICENSE
Copyright 2006-2008 Dave Rolsky, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module.