AnyEvent-MySQL-ConnPool
view release on metacpan or search on metacpan
lib/AnyEvent/MySQL/ConnPool.pm view on Meta::CPAN
=head1 METHODS
=over
=item B<connect_pool>
Returns connected L<AnyEvent::ConnPool> object.
All options for connect_pool are similar to the AnyEvent::MySQL->connect method.
But pool accepts additional options in parameters hashref(4th parameter).
AnyEvent::MySQL->connect_pool($dsn, $user, $password, {PoolSize => 5, CheckInterval => 10, Dispatcher => 0}, $callback);
PoolSize => how many connections should be created. 5 connections by default.
CheckInterval => Interval for ping connections. 10 seconds by default.
Dispatcher => Determines return-value type. If true, connect_pool will return dispatcher object, instead of pool object. You can use dispatcher object
as regular AnyEvent::MySQL connection object, pool will do it's own behind the scene.
=cut
lib/AnyEvent/MySQL/ConnPool.pm view on Meta::CPAN
our $VERSION = 0.07;
sub import {
*{AnyEvent::MySQL::connect_pool} = \&new;
}
=item B<new>
Same thing as connect_pool.
my $connpool = AnyEvent::MySQL::ConnPool->new($dsn, $user, $password, {PoolSize => 5, CheckInterval => 10, Dispatcher => 0}, $callback);
=cut
sub new {
my ($caller, $dsn, $user, $password, $params, $cb) = @_;
my @conn_args = @_;
shift @conn_args;
my $pool_size = delete $params->{PoolSize};
my $check_interval = delete $params->{CheckInterval};
my $dispatcher = delete $params->{Dispatcher};
$pool_size ||= 5;
$check_interval ||= 10;
( run in 0.735 second using v1.01-cache-2.11-cpan-49f99fa48dc )