On Thu, Oct 28, 2010 at 10:20 AM, <qpsmtpdfrose.20.ftu...@spamgourmet.com> wrote: > Matt Sergeant - m...@sergeant.org 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$$