From: Marius Gavrilescu Date: Fri, 19 Dec 2014 11:11:36 +0000 (+0200) Subject: Update cache purging, drop LWP dependency X-Git-Tag: 5999.000_005~109 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=a5d85109e94cca6c36ed5038cde7fed6b046d9da;p=gruntmaster-daemon.git Update cache purging, drop LWP dependency --- diff --git a/Makefile.PL b/Makefile.PL index caff665..7f7b2cd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -39,7 +39,6 @@ WriteMakefile( JSON 0 List::MoreUtils 0 Log::Log4perl 0 - LWP::UserAgent 0 Try::Tiny 0/ }, META_MERGE => { diff --git a/lib/Gruntmaster/Daemon.pm b/lib/Gruntmaster/Daemon.pm index 15f6410..681a141 100644 --- a/lib/Gruntmaster/Daemon.pm +++ b/lib/Gruntmaster/Daemon.pm @@ -17,7 +17,6 @@ use Sys::Hostname qw/hostname/; use Time::HiRes qw/time/; use Try::Tiny; use Log::Log4perl qw/get_logger/; -use LWP::UserAgent; use constant PAGE_SIZE => 10; use constant FORMAT_EXTENSION => { @@ -36,8 +35,6 @@ use constant FORMAT_EXTENSION => { ################################################## my $db; -my $ua = LWP::UserAgent->new; -my @purge_hosts = exists $ENV{PURGE_HOSTS} ? split ' ', $ENV{PURGE_HOSTS} : (); sub safe_can_nodie { my ($type, $sub, $name) = @_; @@ -55,14 +52,6 @@ sub safe_can { safe_can_nodie @_ or get_logger->logdie("No such \l$type: '$name'"); } -sub purge { - get_logger->trace("Purging $_[0]"); - for my $host (@purge_hosts) { - my $req = HTTP::Request->new(PURGE => "http://$host$_[0]"); - $ua->request($req) - } -} - sub process{ my ($job, $jobr) = @_; @@ -155,13 +144,11 @@ sub process{ job => $jobr->id, solved => $solved}); - my $log = $jobr->contest ? 'ct/' . $jobr->contest->id . '/log' : 'log'; - my $page = int (($job + PAGE_SIZE - 1) / PAGE_SIZE); - - purge "/$log/$job"; - purge "/$log/"; - purge "/$log/st"; - purge "/$log/page/$_" for $page - 1, $page, $page + 1; + purge '/log/'; + purge "/log/$job"; + purge '/st/' . $jobr->contest if $jobr->contest; + purge '/us/'; + purge '/us/' . $jobr->owner; } sub got_job{