SOCKETMAP performace (was Re: [Mimedefang] sendmail 8.13.0)
    David F. Skoll 
    dfs at roaringpenguin.com
       
    Thu Jul 29 12:00:42 EDT 2004
    
    
  
On Thu, 29 Jul 2004, Mark wrote:
> Question, though, how will you keep a persistent, say, MySQL connection in
> Perl, for the backend socketmap functionality?
Keep a global variable called $DBH.  Write code like this:
# Put this at the top of your filter
undef $DBH;
sub get_dbh {
    # Re-use if we already have one
    return $DBH if defined($DBH);
    # Get and cache a connection
    $DBH = DBI->connect(....);
    return $DBH;
}
Then in your filter routines, whenever you need the handle:
sub blah {
    my $dbh = get_dbh();
    # Now use dbh here...
}
--
David.
    
    
More information about the MIMEDefang
mailing list