line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Caching; |
2
|
4
|
|
|
4
|
|
1707
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
116
|
|
3
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
80
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
13
|
use Moo; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
16
|
|
6
|
4
|
|
|
4
|
|
1117
|
use Articulate::Syntax qw(instantiate_array); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
23
|
|
7
|
4
|
|
|
4
|
|
906
|
use Articulate::Item; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1359
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Articulate::Caching - store and retrieve content quickly |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 CONFIGURATION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
components: |
20
|
|
|
|
|
|
|
caching: |
21
|
|
|
|
|
|
|
Articulate::Caching: |
22
|
|
|
|
|
|
|
providers: |
23
|
|
|
|
|
|
|
- Articulate::Caching::Native |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 ATTRIBUTE |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head3 providers |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
A list of classes which can be used to cache items. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has providers => ( |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
default => sub { [] }, |
36
|
|
|
|
|
|
|
coerce => sub { instantiate_array(@_) } |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head3 is_cached |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$caching->is_cached( $what, $location ) |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub is_cached { |
48
|
6
|
|
|
6
|
1
|
11
|
my $self = shift; |
49
|
6
|
|
|
|
|
16
|
my $what = shift; |
50
|
6
|
|
|
|
|
7
|
my $location = shift; |
51
|
6
|
|
|
|
|
10
|
foreach my $provider ( @{ $self->providers } ) { |
|
6
|
|
|
|
|
124
|
|
52
|
6
|
50
|
|
|
|
67
|
return 1 if $provider->is_cached( $what, $location ); |
53
|
|
|
|
|
|
|
} |
54
|
6
|
|
|
|
|
24
|
return 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 get_cached |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$caching->get_cached( $what, $location ) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub get_cached { |
64
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
65
|
0
|
|
|
|
|
0
|
my $what = shift; |
66
|
0
|
|
|
|
|
0
|
my $location = shift; |
67
|
0
|
|
|
|
|
0
|
foreach my $provider ( @{ $self->providers } ) { |
|
0
|
|
|
|
|
0
|
|
68
|
0
|
0
|
|
|
|
0
|
return $provider->get_cached( $what, $location ) |
69
|
|
|
|
|
|
|
if $provider->is_cached( $what, $location ); |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
0
|
return undef; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head3 set_cache |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$caching->set_cache( $what, $location, $value ) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub set_cache { |
81
|
4
|
|
|
4
|
1
|
107
|
my $self = shift; |
82
|
4
|
|
|
|
|
5
|
my $what = shift; |
83
|
4
|
|
|
|
|
5
|
my $location = shift; |
84
|
4
|
|
|
|
|
5
|
my $value = shift; |
85
|
4
|
|
|
|
|
94
|
foreach my $provider ( @{ $self->providers } ) { |
|
4
|
|
|
|
|
82
|
|
86
|
4
|
50
|
|
|
|
26
|
return $value if $provider->set_cache( $what, $location, $value ); |
87
|
|
|
|
|
|
|
} |
88
|
0
|
|
|
|
|
0
|
return undef; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head3 clear_cache |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$caching->clear_cache( $what, $location ) |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub clear_cache { |
98
|
6
|
|
|
6
|
1
|
274
|
my $self = shift; |
99
|
6
|
|
|
|
|
10
|
my $what = shift; |
100
|
6
|
|
|
|
|
8
|
my $location = shift; |
101
|
6
|
|
|
|
|
6
|
my $result = 0; |
102
|
6
|
|
|
|
|
8
|
foreach my $provider ( @{ $self->providers } ) { |
|
6
|
|
|
|
|
88
|
|
103
|
6
|
100
|
|
|
|
45
|
$result++ |
104
|
|
|
|
|
|
|
if $provider->clear_cache( $what, $location ); |
105
|
|
|
|
|
|
|
} |
106
|
6
|
|
|
|
|
12
|
return $result; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head3 empty_cache |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
$caching->empty_cache( ) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub empty_cache { |
116
|
6
|
|
|
6
|
1
|
349
|
my $self = shift; |
117
|
6
|
|
|
|
|
12
|
foreach my $provider ( @{ $self->providers } ) { |
|
6
|
|
|
|
|
49
|
|
118
|
6
|
|
|
|
|
2220
|
$provider->empty_cache(); |
119
|
|
|
|
|
|
|
} |
120
|
6
|
|
|
|
|
17
|
return 1; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 SEE ALSO |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * L |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |