summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
Diffstat (limited to 'index.pl')
-rw-r--r--index.pl27
1 files changed, 16 insertions, 11 deletions
diff --git a/index.pl b/index.pl
index 25bd8c0..950e206 100644
--- a/index.pl
+++ b/index.pl
@@ -44,16 +44,10 @@ sub log_api_access {
}
sub get_results {
- my ( $backend, $city, $stop, $expiry ) = @_;
+ my ( $backend, $city, $stop ) = @_;
my $sub_backend;
- $expiry ||= 150;
-
- my $cache = Cache::File->new(
- cache_root => $ENV{VRRFAKEDISPLAY_CACHE} // '/tmp/vrr-fakedisplay',
- default_expires => "${expiry} sec",
- lock_level => Cache::File::LOCK_LOCAL(),
- );
+ my $expiry = 200;
# legacy values
if ( not defined $backend or $backend eq 'vrr' ) {
@@ -80,6 +74,19 @@ sub get_results {
}
}
+ if ( $backend eq 'hafas' ) {
+ $expiry = 120;
+ }
+ elsif ( $backend eq 'aseag' ) {
+ $expiry = 120;
+ }
+
+ my $cache = Cache::File->new(
+ cache_root => $ENV{VRRFAKEDISPLAY_CACHE} // '/tmp/vrr-fakedisplay',
+ default_expires => "${expiry} sec",
+ lock_level => Cache::File::LOCK_LOCAL(),
+ );
+
my $sstr = ("${backend} _ ${stop} _ ${city}");
$sstr =~ tr{a-zA-Z0-9}{_}c;
@@ -240,8 +247,7 @@ sub get_filtered_departures {
my ( @grep_line, @grep_platform, @filtered_results );
- my $data = get_results( $opt{backend}, $opt{city}, $opt{stop},
- $opt{cache_expiry} );
+ my $data = get_results( $opt{backend}, $opt{city}, $opt{stop} );
my $results = $data->{results};
@@ -434,7 +440,6 @@ sub render_json {
city => $self->stash('city') // q{},
stop => $self->stash('stop'),
backend => scalar $self->param('backend'),
- cache_expiry => 120,
filter_line => scalar $self->param('line'),
filter_platform => scalar $self->param('platform'),
hide_regional => 0,