line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::Cache::File; |
2
|
|
|
|
|
|
|
@ISA = 'Text::MicroMason::Cache::Simple'; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
12
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
91
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Array field names |
7
|
4
|
|
|
4
|
|
11
|
use constant LAST_CHECK => 0; |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
169
|
|
8
|
4
|
|
|
4
|
|
34
|
use constant AGE => 1; |
|
4
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
135
|
|
9
|
4
|
|
|
4
|
|
12
|
use constant VALUE => 2; |
|
4
|
|
|
|
|
2
|
|
|
4
|
|
|
|
|
754
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
###################################################################### |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get { |
14
|
26
|
|
|
26
|
1
|
25
|
my ( $self, $file ) = @_; |
15
|
26
|
100
|
|
|
|
55
|
my $entry = $self->SUPER::get( $file ) |
16
|
|
|
|
|
|
|
or return; |
17
|
17
|
50
|
33
|
|
|
69
|
unless (ref($entry) eq 'ARRAY' and @$entry == 3 ) { |
18
|
0
|
|
|
|
|
0
|
Carp::croak("MicroMason: cache '$self' data corrupted; " . |
19
|
|
|
|
|
|
|
"value for '$file' should not be '$entry'"); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
17
|
|
|
|
|
15
|
my $time = time(); |
23
|
17
|
100
|
|
|
|
27
|
if ( $entry->[LAST_CHECK] < $time ) { # don't check more than once per second |
24
|
2
|
|
|
|
|
17
|
my $current_age = -M $file; |
25
|
2
|
50
|
|
|
|
5
|
if ( $entry->[AGE] > $current_age ) { |
26
|
2
|
|
|
|
|
28
|
@$entry = ( 0, 0, undef ); # file has changed; cache invalid |
27
|
2
|
|
|
|
|
9
|
return; |
28
|
|
|
|
|
|
|
} else { |
29
|
0
|
|
|
|
|
0
|
$entry->[LAST_CHECK] = $time; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
15
|
|
|
|
|
54
|
return $entry->[VALUE]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub set { |
36
|
11
|
|
|
11
|
1
|
52
|
my ($self, $file, $sub) = @_; |
37
|
11
|
|
|
|
|
141
|
$self->SUPER::set( $file => [ time(), -M $file, $sub ] ); |
38
|
11
|
|
|
|
|
54
|
return $sub; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
###################################################################### |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |