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 => {
##################################################
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) = @_;
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) = @_;
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{