Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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( "dbi:Sybase:server=sql.example.com", $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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2015-07-07 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls