Re: Singleton Persistence
Vincent Veyron <[email protected]>
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Message-ID | <[email protected]> |
Le lundi 03 février 2014 à 21:49 +0000, John ORourke a écrit :
> I do it by treating the request as something transient - in other
> words assuming that interpreter state is maintained between requests,
> and resetting or recreating all the objects I use to process the
> request in my fixup handler.
>
pnotes is very handy to pass structures across all phases of a request.
I use PerlHeaderParserHandler :
http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlHeaderParserHandler
In this I write :
my $dbh = DBI->connect_cached( "proper connection string here") ;
$r->pnotes( 'dbh' => $dbh ) ;
Then all the subsequent handlers need is :
sub handler {
my $dbh = $r->pnotes('dbh') ;
}
To reuse the database handle. Very convenient.
--
http://litigios.libremen.com
Gestión de litigios y de expedientes de seguros de siniestros para el
servicio jurÃdico