DBDB: use realtime cache for carriage composition requests

This commit is contained in:
Birte Kristina Friesel 2024-05-30 11:53:33 +02:00
parent 2576a463db
commit 9442572084
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
2 changed files with 9 additions and 8 deletions

View file

@ -362,11 +362,12 @@ sub startup {
dbdb => sub { dbdb => sub {
my ($self) = @_; my ($self) = @_;
state $dbdb = Travelynx::Helper::DBDB->new( state $dbdb = Travelynx::Helper::DBDB->new(
log => $self->app->log, log => $self->app->log,
cache => $self->app->cache_iris_main, main_cache => $self->app->cache_iris_main,
root_url => $self->base_url_for('/')->to_abs, realtime_cache => $self->app->cache_iris_rt,
user_agent => $self->ua, root_url => $self->base_url_for('/')->to_abs,
version => $self->app->config->{version}, user_agent => $self->ua,
version => $self->app->config->{version},
); );
} }
); );

View file

@ -31,7 +31,7 @@ sub has_wagonorder_p {
my $api_ts = $ts->strftime('%Y%m%d%H%M'); my $api_ts = $ts->strftime('%Y%m%d%H%M');
my $url my $url
= "https://ist-wr.noncd.db.de/wagenreihung/1.0/${train_no}/${api_ts}"; = "https://ist-wr.noncd.db.de/wagenreihung/1.0/${train_no}/${api_ts}";
my $cache = $self->{cache}; my $cache = $self->{realtime_cache};
my $promise = Mojo::Promise->new; my $promise = Mojo::Promise->new;
if ( my $content = $cache->get("HEAD $url") ) { if ( my $content = $cache->get("HEAD $url") ) {
@ -73,7 +73,7 @@ sub get_wagonorder_p {
my $url my $url
= "https://ist-wr.noncd.db.de/wagenreihung/1.0/${train_no}/${api_ts}"; = "https://ist-wr.noncd.db.de/wagenreihung/1.0/${train_no}/${api_ts}";
my $cache = $self->{cache}; my $cache = $self->{realtime_cache};
my $promise = Mojo::Promise->new; my $promise = Mojo::Promise->new;
if ( my $content = $cache->thaw($url) ) { if ( my $content = $cache->thaw($url) ) {
@ -113,7 +113,7 @@ sub get_stationinfo_p {
my $url = "https://lib.finalrewind.org/dbdb/s/${eva}.json"; my $url = "https://lib.finalrewind.org/dbdb/s/${eva}.json";
my $cache = $self->{cache}; my $cache = $self->{main_cache};
my $promise = Mojo::Promise->new; my $promise = Mojo::Promise->new;
if ( my $content = $cache->thaw($url) ) { if ( my $content = $cache->thaw($url) ) {