MQdb
view release on metacpan or search on metacpan
lib/MQdb/DBStream.pm view on Meta::CPAN
# $Id: DBStream.pm,v 1.15 2009/06/03 06:47:32 severin Exp $
=head1 NAME
MQdb::DBStream - DESCRIPTION of Object
=head1 SYNOPSIS
A simplified object to manage a collection of information related to streaming data from
a database. at least with MYSQL, the perl driver does odd caching so to stream one
needs to create a new database connection in order to stream
=head1 DESCRIPTION
=head1 CONTACT
Jessica Severin <jessica.severin@gmail.com>
=head1 LICENSE
lib/MQdb/DBStream.pm view on Meta::CPAN
#################################################
# Class methods
#################################################
sub class { return "DBStream"; }
=head2 set_stream_useresult_behaviour
Description : sets a global behaviour for all DBStreams.
setting use_result to "on" will leave the results on the database and
will keep the database connection open durring streaming.
Both methods have similar speed performance, but keeping the results
on the database server means the client uses essentially no memory.
The risk of turning this on is that the the database connection remains open
and there is risk of it timing out if processing takes a long time to stream all data.
When turned off, the entire result set is transfered in bulk to the driver (DBD::mysql)
and streaming happens from the underlying driver code and the perl code layer.
Default is "off" since this is safer but one risks needing lots of memory on the client.
Parameter[1] : 1 or "y" or "on" turns the use_result on and keeps the database connection open
Returntype : none
Exceptions : none
Example : MQdb::DBStream->set_stream_useresult_behaviour(1);
=cut
sub set_stream_useresult_behaviour {
my $class = shift;
lib/MQdb/DBStream.pm view on Meta::CPAN
if($args{'db'}) { $self->database($args{'db'}); }
if($args{'class'}) { $self->stream_class($args{'class'}); }
}
=head2 stream_database
Description: this is an internal system method.
Needs to have two database connections open, one for the active
stream handle, and one for lazy-loading additional data on the returned
objects. This is used to set the database which is the one streaming objects
Arg (1) : $database (MQdb::Database) for setting
Returntype : MQdb::Database
Exceptions : none
Callers : MQdb::MappedQuery
=cut
sub stream_database {
my $self = shift;
( run in 0.554 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )