Re: How to drop an email and have global history

[email protected] (David Nicol)
Newsgroups perl.qpsmtpd
Message-ID <[email protected]>
On Thu, Oct 28, 2010 at 10:20 AM,
<[email protected]> wrote:
> Matt Sergeant - [email protected] wrote:

>>> I'm guessing memcached would be useful here or a sqlite db?
>>
>> Yes or some sort of db file like BDB, though lots of people seem to have
>> reliability problems with those (myself included).
>>
> Ah ok.

this is exactly the kind of thing that DirDB is designed for and good
at. Expirations can be efficiently effected by having two DirDB hashes
like so:

     tie my %Issues0 => DirDB => "issueDB/issues0";
     tie my %Issues1 => DirDB => "issueDB/issues1";

and when you are looking something up, sanitize they key (as it will
be going into a file name) and fall back to the second one

    my $issue = do {
             my $_key = $key;
             $_key =~ s/\W/X/g; # or something -- be creative
             sleep 1 until !mkdir ("issueDB/LOCK", 0700);
             $Issues0{$_key} or $Issues1{$_key}
             rmdir "issueDB/LOCK";
    };

and do expirations by running from cron a script containing something like

     while true
     do
       mkdir issueDB/LOCK  && break
       sleep 1
     done
     mv issueDB/issues1 issueDB/issuesX$$
     mv issueDB/issues0 issueDB/issues1
     mkdir issueDB/issues0
     rmdir "issueDB/LOCK";
     rm -rf  issueDB/issuesX$$
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.