| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Articulate::Caching; |
|
2
|
6
|
|
|
6
|
|
3693
|
use strict; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
219
|
|
|
3
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
165
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
28
|
use Moo; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
32
|
|
|
6
|
6
|
|
|
6
|
|
1756
|
use Articulate::Syntax qw(instantiate_array); |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
50
|
|
|
7
|
6
|
|
|
6
|
|
1375
|
use Articulate::Item; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
2185
|
|
|
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
|
4
|
|
|
4
|
1
|
10
|
my $self = shift; |
|
49
|
4
|
|
|
|
|
9
|
my $what = shift; |
|
50
|
4
|
|
|
|
|
7
|
my $location = shift; |
|
51
|
4
|
|
|
|
|
6
|
foreach my $provider ( @{ $self->providers } ) { |
|
|
4
|
|
|
|
|
86
|
|
|
52
|
4
|
50
|
|
|
|
49
|
return 1 if $provider->is_cached( $what, $location ); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
4
|
|
|
|
|
20
|
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
|
164
|
my $self = shift; |
|
82
|
4
|
|
|
|
|
8
|
my $what = shift; |
|
83
|
4
|
|
|
|
|
8
|
my $location = shift; |
|
84
|
4
|
|
|
|
|
10
|
my $value = shift; |
|
85
|
4
|
|
|
|
|
4
|
foreach my $provider ( @{ $self->providers } ) { |
|
|
4
|
|
|
|
|
136
|
|
|
86
|
4
|
50
|
|
|
|
51
|
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
|
4
|
|
|
4
|
1
|
248
|
my $self = shift; |
|
99
|
4
|
|
|
|
|
9
|
my $what = shift; |
|
100
|
4
|
|
|
|
|
6
|
my $location = shift; |
|
101
|
4
|
|
|
|
|
5
|
my $result = 0; |
|
102
|
4
|
|
|
|
|
6
|
foreach my $provider ( @{ $self->providers } ) { |
|
|
4
|
|
|
|
|
82
|
|
|
103
|
4
|
100
|
|
|
|
88
|
$result++ |
|
104
|
|
|
|
|
|
|
if $provider->clear_cache( $what, $location ); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
4
|
|
|
|
|
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
|
348
|
my $self = shift; |
|
117
|
6
|
|
|
|
|
10
|
foreach my $provider ( @{ $self->providers } ) { |
|
|
6
|
|
|
|
|
36
|
|
|
118
|
6
|
|
|
|
|
2678
|
$provider->empty_cache(); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
6
|
|
|
|
|
20
|
return 1; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * L |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * L |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |