summaryrefslogtreecommitdiff
path: root/cgi/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-02-10 16:39:10 +0100
committerDaniel Friesel <derf@finalrewind.org>2013-02-10 16:39:10 +0100
commit00d2c8eac5bcf13579c75fa4a5ccfd117b4d2adf (patch)
treec010b75f8d9cfd5531b5a5a7dc24e67339248a13 /cgi/index.pl
parent945379f1ca34642556bccefe637c3d444d893210 (diff)
automatically refresh display after cache expiry
Diffstat (limited to 'cgi/index.pl')
-rw-r--r--cgi/index.pl14
1 files changed, 9 insertions, 5 deletions
diff --git a/cgi/index.pl b/cgi/index.pl
index 6abb47a..06eb677 100644
--- a/cgi/index.pl
+++ b/cgi/index.pl
@@ -7,12 +7,14 @@ use utf8;
our $VERSION = '0.03';
+my $refresh_interval = 900;
+
sub get_results_for {
my ($station) = @_;
my $cache = Cache::File->new(
cache_root => '/tmp/db-fake',
- default_expires => '900 sec'
+ default_expires => $refresh_interval . ' sec',
);
my $results = $cache->thaw($station);
@@ -87,7 +89,8 @@ sub handle_request {
$info = undef;
}
if ($info) {
- $info =~ s{ ^ (?: ca\. \s* )? \+ (\d+) }{Verspätung ca. $1 Minuten}x;
+ $info
+ =~ s{ ^ (?: ca\. \s* )? \+ (\d+) }{Verspätung ca. $1 Minuten}x;
$info =~ s{ 1 \s Minute\Kn }{}x;
}
push(
@@ -105,9 +108,10 @@ sub handle_request {
$self->render(
$template,
- departures => \@departures,
- version => $VERSION,
- title => "departures for ${station}"
+ departures => \@departures,
+ version => $VERSION,
+ title => "departures for ${station}",
+ refresh_interval => $refresh_interval + 3,
);
}