summaryrefslogtreecommitdiff
path: root/lib/Travel/Status/DE
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-11-29 17:35:54 +0100
committerDaniel Friesel <derf@finalrewind.org>2015-11-29 17:35:54 +0100
commitaa1ff3da725ff69336cb243fa316a800c75aa0f3 (patch)
tree8e39509958e38c4f99acf28b6e9d0acd60accf2e /lib/Travel/Status/DE
parentc90be68e41b7f93172cd4fea40988eefda8bf455 (diff)
actually use cache
Diffstat (limited to 'lib/Travel/Status/DE')
-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 {