| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Lengthen::Cached; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1157
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
85
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw( WWW::Lengthen ); |
|
|
1
|
|
|
|
|
11
|
|
|
|
1
|
|
|
|
|
319
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub setup_cached { |
|
9
|
0
|
|
|
0
|
1
|
|
my ($self, $cache) = @_; |
|
10
|
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
croak "cached doesn't have get" unless $cache->can('get'); |
|
12
|
0
|
0
|
|
|
|
|
croak "cached doesn't have set" unless $cache->can('set'); |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
$self->{cache} = $cache; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
|
sub cache { shift->{cache} } |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub try { |
|
20
|
0
|
|
|
0
|
1
|
|
my ($self, $url) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $longer_url; |
|
23
|
0
|
0
|
|
|
|
|
if ( $longer_url = $self->cache->get( "www-lengthen:$url" ) ) { |
|
24
|
0
|
|
|
|
|
|
return $longer_url; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$longer_url = $self->SUPER::try( $url ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if ( defined $longer_url ) { |
|
30
|
0
|
|
|
|
|
|
$self->cache->set( "www-lengthen:$url" => $longer_url ); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
0
|
|
|
|
|
|
return $longer_url; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |