
Martin.Schuster1 at infineon
Nov 30, 2011, 12:30 AM
Post #3 of 3
(200 views)
Permalink
|
On 11/29/2011 04:52 PM, Klaus Ethgen wrote: > Hello folks, > Servus Klaus, > I want to implement the relevant part of amavis spamchecking direct in > exim using embedded perl. The solution need to get several parameter > from ldap. So I plan to do the ldap query only once and cache it in a > global variable inside perl. > You could use Shared Memory for the cache. (you will need to cpan -i IPC::Cache on the server though...) code-snippet: use IPC::Cache; # init shared cache my $cache = new IPC::Cache( { namespace => 'exim', expires_in => 3600 } ); # allow forced flush via commandline if ($#ARGV == 0 && $ARGV[0] eq '--clear') { $cache->clear; exit; } # Try to use the info from cache my $bycache = $cache->get($user); if (defined $bycache) { return $bycache; } # Otherwise do all the LDAP stuff my $mail = ldap_lookup($user); # and put it into the cache $cache->set($user, $mail); return $mail; hth, -- Infineon Technologies IT-Services GmbH Martin.Schuster1 [at] infineon Lakeside B05, 9020 Klagenfurt, Austria Martin Schuster FB: LG Klagenfurt, FN 246787y +43 5 1777 3517
|