diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-08-13 14:55:52 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-08-13 14:55:52 +0200 |
commit | f988d539bb3e41c52dcfd5cb1942261a14d77705 (patch) | |
tree | 97c2fe459ec35c2fce95595d574aecb3588f8e42 /lib | |
parent | ca372be9811a183d11a00abd539442a9e2e53cae (diff) |
marudor: cache negative replies4.5.2
Diffstat (limited to 'lib')
-rw-r--r-- | lib/DBInfoscreen/Helper/Marudor.pm | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/DBInfoscreen/Helper/Marudor.pm b/lib/DBInfoscreen/Helper/Marudor.pm index 91b34e3..cdc90f4 100644 --- a/lib/DBInfoscreen/Helper/Marudor.pm +++ b/lib/DBInfoscreen/Helper/Marudor.pm @@ -34,11 +34,13 @@ sub get_json_p { my $promise = Mojo::Promise->new; if ( my $content = $cache->thaw($url) ) { + $self->{log}->debug("marudor->get_json_p($url): cached"); + if ( $content->{error} ) { + return $promise->reject( $content->{error} ); + } return $promise->resolve($content); } - $self->{log}->debug("get_json_p($url)"); - $self->{user_agent}->request_timeout(5)->get_p( $url => $self->{header} ) ->then( sub { @@ -48,6 +50,7 @@ sub get_json_p { $self->{log}->debug( "marudor->get_json_p($url): HTTP $err->{code} $err->{message}" ); + $cache->freeze( $url, { error => $err->{message} } ); $promise->reject( "GET $url returned HTTP $err->{code} $err->{message}"); return; @@ -72,6 +75,7 @@ sub get_json_p { sub { my ($err) = @_; $self->{log}->debug("marudor->get_json_p($url): $err"); + $cache->freeze( $url, { error => $err } ); $promise->reject($err); return; } |