Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Simple DBI handle caching.

by kyle (Abbot)
on May 11, 2011 at 16:10 UTC ( #904196=note: print w/ replies, xml ) Need Help??

in reply to Simple DBI handle caching.

I guess that wasn't so bad.

use English '-no_match_vars'; sub dbh { state $dbh; state $dbh_pid; if ( defined $dbh_pid && $PROCESS_ID != $dbh_pid ) { my $child_dbh = $dbh->clone; $dbh->{InactiveDestroy} = 1; $dbh = $child_dbh; $dbh_pid = $PROCESS_ID; $L->debug( "cloned database connection in PID $dbh_pid" ); } if ( ! defined $dbh ) { my ($u,$p) = ('user',':)'); $dbh = DBI->connect( "", $u, $p, { RaiseError => 1 }, ); $dbh->do( $initialization_stuff ); $dbh_pid = $PROCESS_ID; $L->debug( "made new database connection in PID $dbh_pid" ); } return $dbh; }

Comment on Re: Simple DBI handle caching.
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://904196]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2015-12-01 00:07 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (788 votes), past polls