| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::MicroMason::CompileCache; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1666
|
use strict; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
87
|
|
|
4
|
4
|
|
|
4
|
|
11
|
use Carp; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
768
|
|
|
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
|
423
|
my $self = shift; |
|
22
|
64
|
|
|
|
|
78
|
my ( $src_type, $src_data, %options ) = @_; |
|
23
|
64
|
50
|
|
|
|
83
|
my $cache = $self->_compile_cache( $src_type ) |
|
24
|
|
|
|
|
|
|
or return $self->NEXT('compile', @_); |
|
25
|
64
|
|
|
|
|
133
|
my $key = $self->cache_key(@_); |
|
26
|
64
|
100
|
|
|
|
113
|
$cache->get( $key ) or $cache->set( $key, |
|
27
|
|
|
|
|
|
|
$self->NEXT('compile', @_), |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _compile_cache { |
|
32
|
64
|
|
|
64
|
|
49
|
my ($self, $type) = @_; |
|
33
|
64
|
50
|
|
|
|
109
|
$CACHE_CLASS{$type} or return; |
|
34
|
|
|
|
|
|
|
|
|
35
|
64
|
|
66
|
|
|
222
|
$self->{compile_cache}{$type} ||= $CACHE_CLASS{$type}->new(); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
###################################################################### |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |