From 1fb2c0b50e098207b484022f21643428555bbc1a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 7 Jun 2019 16:31:30 +0200 Subject: use global cache objects, also cache wagon order --- lib/DBInfoscreen.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'lib/DBInfoscreen.pm') diff --git a/lib/DBInfoscreen.pm b/lib/DBInfoscreen.pm index 548fce2..d83f58f 100644 --- a/lib/DBInfoscreen.pm +++ b/lib/DBInfoscreen.pm @@ -4,6 +4,7 @@ use Mojo::Base 'Mojolicious'; # Copyright (C) 2011-2019 Daniel Friesel # License: 2-Clause BSD +use Cache::File; use Travel::Status::DE::HAFAS; use Travel::Status::DE::HAFAS::StopFinder; use Travel::Status::DE::IRIS::Stations; @@ -23,6 +24,42 @@ my %default = ( sub startup { my ($self) = @_; + $self->attr( + cache_hafas => sub { + my ($self) = @_; + return Cache::File->new( + cache_root => $ENV{DBFAKEDISPLAY_HAFAS_CACHE} + // '/tmp/dbf-hafas', + default_expires => '180 seconds', + lock_level => Cache::File::LOCK_LOCAL(), + ); + } + ); + + $self->attr( + cache_iris_main => sub { + my ($self) = @_; + return Cache::File->new( + cache_root => $ENV{DBFAKEDISPLAY_IRIS_CACHE} + // '/tmp/dbf-iris-main', + default_expires => '6 hours', + lock_level => Cache::File::LOCK_LOCAL(), + ); + } + ); + + $self->attr( + cache_iris_rt => sub { + my ($self) = @_; + return Cache::File->new( + cache_root => $ENV{DBFAKEDISPLAY_IRISRT_CACHE} + // '/tmp/dbf-iris-realtime', + default_expires => '70 seconds', + lock_level => Cache::File::LOCK_LOCAL(), + ); + } + ); + $self->helper( 'handle_no_results' => sub { my ( $self, $backend, $station, $errstr ) = @_; -- cgit v1.2.3