Hi Josh,
thanks for the lightning fast response!
On Mon, 31 Oct 2005 04:31:50 -0500, Josh Danziger wrote:
> The DBI package has a built in function call for pooled database
> connections. Simply calling DBI->connect_cached(...) instead of
> DBI->connect(...) with the same exact parameters will get the cached copy
> if (a) it exists and (b) it is still alive. This would be preferred for
> obvious reasons.
I'm familiar with connect_cached, however I don't think it will work without
further changes because the connection gets torn down when the object goes
out of scope, doesn't it?
Do you have an idea how persistency can be integrated into the DBH plugin?
I think it's a functionality that will be useful to many people.
Perhaps the handles can be stored inside a package-level variable
in the CAP:DBI module?
There could be a MD5-hash over the parameters (host, port, db, user, password)
so it doesn't accidentally hand out the wrong database handle
if different requests ask for different handles.
Again, I'd rather hack this into CAP:DBH instead of ripping CAP::DBH
outside my script.
Do you think something like this in CAP::DBH.pm could work?
...
our %Sticky_dbhs; # storage to make DB-connections persistent
...
sub dbh {
...
$self->{__DBH}{$name} =
DBI->connect_cached(@{ $self->{__DBH_CONFIG}{$name} });
$Sticky_dbhs{ md5(join('',@{ $self->{__DBH_CONFIG}{$name} }) } =
$self->{__DBH}{$name};
...
-Sven
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.