summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE/IRIS.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Travel/Status/DE/IRIS.pm')
-rw-r--r--lib/Travel/Status/DE/IRIS.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/IRIS.pm b/lib/Travel/Status/DE/IRIS.pm
index d178c7e..e76e1f9 100644
--- a/lib/Travel/Status/DE/IRIS.pm
+++ b/lib/Travel/Status/DE/IRIS.pm
@@ -125,6 +125,16 @@ sub get_with_cache {
say "GET $url";
}
+ if ($cache) {
+ my $content = $cache->thaw($url);
+ if ($content) {
+ if ( $self->{developer_mode} ) {
+ say ' cache hit';
+ }
+ return ( ${$content}, undef );
+ }
+ }
+
say ' cache miss';
my $ua = $self->{user_agent};
my $res = $ua->get($url);
@@ -132,8 +142,13 @@ sub get_with_cache {
if ( $res->is_error ) {
return ( undef, $res->status_line );
}
+ my $content = $res->decoded_content;
+
+ if ($cache) {
+ $cache->freeze( $url, \$content );
+ }
- return ( $res->decoded_content, undef );
+ return ( $content, undef );
}
sub get_station {