Commit aa1ff3da authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

actually use cache

parent c90be68e
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -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 {