line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::Driver::Metacache; |
2
|
|
|
|
|
|
|
$CHI::Driver::Metacache::VERSION = '0.60'; |
3
|
20
|
|
|
20
|
|
81
|
use CHI::Constants qw(CHI_Meta_Namespace); |
|
20
|
|
|
|
|
26
|
|
|
20
|
|
|
|
|
897
|
|
4
|
20
|
|
|
20
|
|
97
|
use Moo; |
|
20
|
|
|
|
|
27
|
|
|
20
|
|
|
|
|
131
|
|
5
|
20
|
|
|
20
|
|
9016
|
use strict; |
|
20
|
|
|
|
|
37
|
|
|
20
|
|
|
|
|
499
|
|
6
|
20
|
|
|
20
|
|
91
|
use warnings; |
|
20
|
|
|
|
|
24
|
|
|
20
|
|
|
|
|
6028
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'meta_cache' => ( is => 'lazy', clearer => 'clear_meta_cache', predicate => 'has_meta_cache' ); |
9
|
|
|
|
|
|
|
has 'owner_cache' => ( is => 'ro', weak_ref => 1 ); |
10
|
|
|
|
|
|
|
has 'owner_namespace' => ( is => 'lazy', clearer => 'clear_owner_namespace', predicate => 'has_owner_namespace' ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _build_meta_cache { |
13
|
74
|
|
|
74
|
|
3050
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
74
|
|
|
|
|
262
|
my $owner_cache = $self->owner_cache; |
16
|
74
|
|
|
|
|
194
|
my %params = %{ $owner_cache->constructor_params }; |
|
74
|
|
|
|
|
1212
|
|
17
|
74
|
|
|
|
|
326
|
delete( @params{qw(l1_cache mirror_cache parent_cache chi_root_class)} ); |
18
|
74
|
|
|
|
|
2050
|
$params{label} = $owner_cache->label . " (meta)"; |
19
|
74
|
|
|
|
|
370
|
$params{namespace} = CHI_Meta_Namespace; |
20
|
74
|
|
|
|
|
588
|
return $owner_cache->chi_root_class->new(%params); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _build_owner_namespace { |
24
|
74
|
|
|
74
|
|
3347
|
my ($self) = @_; |
25
|
|
|
|
|
|
|
|
26
|
74
|
|
|
|
|
1504
|
return $self->owner_cache->namespace; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get { |
30
|
1992
|
|
|
1992
|
0
|
15622
|
my ( $self, $key ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1992
|
|
|
|
|
37028
|
return $self->meta_cache->fetch( $self->_prefixed_key($key) ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub set { |
36
|
1570
|
|
|
1570
|
0
|
20103
|
my ( $self, $key, $value ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
1570
|
|
|
|
|
29007
|
return $self->meta_cache->store( $self->_prefixed_key($key), $value ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub remove { |
42
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $key, $value ) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
return $self->meta_cache->remove( $self->_prefixed_key($key) ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _prefixed_key { |
48
|
3562
|
|
|
3562
|
|
23575
|
my ( $self, $key ) = @_; |
49
|
|
|
|
|
|
|
|
50
|
3562
|
|
|
|
|
63096
|
return $self->owner_namespace . ":" . $key; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |