| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::WithCache::Backend; |
|
2
|
1
|
|
|
1
|
|
852
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
BEGIN { |
|
5
|
1
|
|
|
1
|
|
7030
|
if (MooseX::WithCache::DEBUG()) { |
|
6
|
|
|
|
|
|
|
require Data::Dump; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
} |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has cache_type => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
isa => 'Str', |
|
13
|
|
|
|
|
|
|
lazy_build => 1, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has can_coerce => ( |
|
17
|
|
|
|
|
|
|
is => 'ro', |
|
18
|
|
|
|
|
|
|
isa => 'Bool', |
|
19
|
|
|
|
|
|
|
default => 0 |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has methods => ( |
|
23
|
|
|
|
|
|
|
is => 'ro', |
|
24
|
|
|
|
|
|
|
isa => 'HashRef', |
|
25
|
|
|
|
|
|
|
lazy_build => 1 |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
0
|
|
|
sub _build_cache_type {} |
|
29
|
|
|
|
|
|
|
sub _build_methods { |
|
30
|
|
|
|
|
|
|
return { |
|
31
|
|
|
|
|
|
|
cache_get => sub { |
|
32
|
7
|
|
|
7
|
|
2573
|
my ($self, $key) = @_; |
|
33
|
7
|
|
|
|
|
33
|
my $cache = $self->__get_cache(); |
|
34
|
7
|
100
|
66
|
|
|
377
|
if ($self->cache_disabled || ! $cache) { |
|
35
|
3
|
|
|
|
|
5
|
if (MooseX::WithCache::DEBUG()) { |
|
36
|
|
|
|
|
|
|
$self->cache_debug(blessed $self, "cache_get: Cache disabled"); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
3
|
|
|
|
|
15
|
return (); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
221
|
my $keygen = $self->cache_key_generator; |
|
42
|
4
|
100
|
|
|
|
28
|
my $cache_key = $keygen ? $keygen->generate($key) : $key; |
|
43
|
4
|
|
|
|
|
365
|
my $cache_ret = $cache->get($cache_key); |
|
44
|
4
|
|
|
|
|
2772
|
if (MooseX::WithCache::DEBUG()) { |
|
45
|
|
|
|
|
|
|
$self->cache_debug( |
|
46
|
|
|
|
|
|
|
blessed $self, |
|
47
|
|
|
|
|
|
|
"cache_get:\n + status:", |
|
48
|
|
|
|
|
|
|
defined $cache_ret ? "[HIT]" : "[MISS]", |
|
49
|
|
|
|
|
|
|
"\n + key =", ( |
|
50
|
|
|
|
|
|
|
$cache_key ? ( |
|
51
|
|
|
|
|
|
|
$keygen ? Data::Dump::dump($key) . " ($cache_key)" : $cache_key |
|
52
|
|
|
|
|
|
|
) : '(null)' ), |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
4
|
|
|
|
|
16
|
return $cache_ret; |
|
56
|
|
|
|
|
|
|
}, |
|
57
|
|
|
|
|
|
|
cache_set => sub { |
|
58
|
5
|
|
|
5
|
|
1025
|
my ($self, $key, $value, $expire) = @_; |
|
59
|
5
|
|
|
|
|
18
|
my $cache = $self->__get_cache(); |
|
60
|
5
|
100
|
66
|
|
|
208
|
if ($self->cache_disabled || ! $cache) { |
|
61
|
3
|
|
|
|
|
5
|
if (MooseX::WithCache::DEBUG()) { |
|
62
|
|
|
|
|
|
|
$self->cache_debug(blessed $self, "cache_set: Cache disabled"); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
3
|
|
|
|
|
8
|
return (); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
81
|
my $keygen = $self->cache_key_generator; |
|
68
|
2
|
100
|
|
|
|
9
|
my $cache_key = $keygen ? $keygen->generate($key) : $key; |
|
69
|
2
|
|
|
|
|
74
|
if (MooseX::WithCache::DEBUG()) { |
|
70
|
|
|
|
|
|
|
$self->cache_debug( |
|
71
|
|
|
|
|
|
|
blessed $self, |
|
72
|
|
|
|
|
|
|
"cache_set:\n + key =", ( |
|
73
|
|
|
|
|
|
|
$cache_key ? ( |
|
74
|
|
|
|
|
|
|
$keygen ? Data::Dump::dump($key) . " ($cache_key)" : $cache_key |
|
75
|
|
|
|
|
|
|
) : '(null)' ), |
|
76
|
|
|
|
|
|
|
"\n + expire =", |
|
77
|
|
|
|
|
|
|
($expire || '(null)'), |
|
78
|
|
|
|
|
|
|
MooseX::WithCache::DEBUG() > 1 ? ( |
|
79
|
|
|
|
|
|
|
"\n + value =", |
|
80
|
|
|
|
|
|
|
($value ? Data::Dump::dump($value) : '(null)'), |
|
81
|
|
|
|
|
|
|
) : '', |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
2
|
|
|
|
|
15
|
return $cache->set($cache_key, $value, $expire); |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
|
|
|
|
|
|
cache_del => sub { |
|
87
|
0
|
|
|
0
|
|
0
|
my ($self, $key) = @_; |
|
88
|
0
|
|
|
|
|
0
|
my $cache = $self->__get_cache(); |
|
89
|
0
|
0
|
0
|
|
|
0
|
if ($self->cache_disabled || ! $cache) { |
|
90
|
0
|
|
|
|
|
0
|
if (MooseX::WithCache::DEBUG()) { |
|
91
|
|
|
|
|
|
|
$self->cache_debug(blessed $self, "cache_del: Cache disabled"); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
0
|
|
|
|
|
0
|
return (); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
0
|
my $keygen = $self->cache_key_generator; |
|
97
|
0
|
0
|
|
|
|
0
|
my $cache_key = $keygen ? $keygen->generate($key) : $key; |
|
98
|
0
|
|
|
|
|
0
|
if (MooseX::WithCache::DEBUG()) { |
|
99
|
|
|
|
|
|
|
$self->cache_debug( |
|
100
|
|
|
|
|
|
|
blessed $self, |
|
101
|
|
|
|
|
|
|
"cache_del:\n + key =", ( |
|
102
|
|
|
|
|
|
|
$cache_key ? ( |
|
103
|
|
|
|
|
|
|
$keygen ? Data::Dump::dump($key) . " ($cache_key)" : $cache_key |
|
104
|
|
|
|
|
|
|
) : '(null)' ), |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
0
|
|
|
|
|
0
|
return $cache->delete($cache_key); |
|
108
|
|
|
|
|
|
|
}, |
|
109
|
1
|
|
|
1
|
|
18
|
}; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
|
|
1
|
|
8
|
no Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
MooseX::WithCache::Backend - Base Class For All Backends |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package MyBackend; |
|
127
|
|
|
|
|
|
|
use Moose; |
|
128
|
|
|
|
|
|
|
extends 'MooseX::WithCache::Backend'; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 METHODS |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 cache_type |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Holds the Moose type of the cache attribute |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 methods |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Holds the map of methods that this backend will install on the applicant class. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |