line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::CompileCache; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2257
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
121
|
|
4
|
4
|
|
|
4
|
|
38
|
use Carp; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
999
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Text::MicroMason::Cache::Simple; |
7
|
|
|
|
|
|
|
require Text::MicroMason::Cache::File; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
###################################################################### |
10
|
|
|
|
|
|
|
# What cache class should we use for each src_type? |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %CACHE_CLASS = ( |
13
|
|
|
|
|
|
|
file => 'Text::MicroMason::Cache::File', |
14
|
|
|
|
|
|
|
text => 'Text::MicroMason::Cache::Simple', |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
###################################################################### |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# $code_ref = compile( file => $filename ); |
20
|
|
|
|
|
|
|
sub compile { |
21
|
64
|
|
|
64
|
1
|
816
|
my $self = shift; |
22
|
64
|
|
|
|
|
125
|
my ( $src_type, $src_data, %options ) = @_; |
23
|
64
|
50
|
|
|
|
153
|
my $cache = $self->_compile_cache( $src_type ) |
24
|
|
|
|
|
|
|
or return $self->NEXT('compile', @_); |
25
|
64
|
|
|
|
|
186
|
my $key = $self->cache_key(@_); |
26
|
64
|
100
|
|
|
|
160
|
$cache->get( $key ) or $cache->set( $key, |
27
|
|
|
|
|
|
|
$self->NEXT('compile', @_), |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _compile_cache { |
32
|
64
|
|
|
64
|
|
118
|
my ($self, $type) = @_; |
33
|
64
|
50
|
|
|
|
158
|
$CACHE_CLASS{$type} or return; |
34
|
|
|
|
|
|
|
|
35
|
64
|
|
66
|
|
|
282
|
$self->{compile_cache}{$type} ||= $CACHE_CLASS{$type}->new(); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
###################################################################### |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |