Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Creating Socket Connections that are persistent across multiple page loads in a single web sessionby Anonymous Monk |
on Jan 05, 2011 at 20:54 UTC ( [id://880676]=note: print w/replies, xml ) | Need Help?? |
#!/usr/bin/perl -w
use strict;
package MyConnections;
use vars ($dbh);
unless($dbh) {
# do stuff here, establish connection/etc
}
1;
Then simply include a module as similar to the above if you're already using Apache mod_perl/registry. The module remains persistent (compiled) per each HTTPD process Apache spawns, thus any program which uses the above module would have access to the already instantiated $dbh. We use this method for memcached and database handles - the only caveat being that you have to manage one connection per httpd process on the server but it works very well.
In Section
Seekers of Perl Wisdom
|
|