line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Zonemaster::Engine::Nameserver::Cache; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
173
|
use version; our $VERSION = version->declare("v1.0.4"); |
|
26
|
|
|
|
|
53
|
|
|
26
|
|
|
|
|
231
|
|
4
|
|
|
|
|
|
|
|
5
|
26
|
|
|
26
|
|
2657
|
use 5.014002; |
|
26
|
|
|
|
|
85
|
|
6
|
26
|
|
|
26
|
|
144
|
use warnings; |
|
26
|
|
|
|
|
78
|
|
|
26
|
|
|
|
|
748
|
|
7
|
|
|
|
|
|
|
|
8
|
26
|
|
|
26
|
|
123
|
use Moose; |
|
26
|
|
|
|
|
50
|
|
|
26
|
|
|
|
|
178
|
|
9
|
26
|
|
|
26
|
|
153167
|
use Zonemaster::Engine; |
|
26
|
|
|
|
|
60
|
|
|
26
|
|
|
|
|
5268
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our %object_cache; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'data' => ( is => 'ro', isa => 'HashRef', default => sub { {} } ); |
14
|
|
|
|
|
|
|
has 'address' => ( is => 'ro', isa => 'Zonemaster::Engine::Net::IP', required => 1 ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
around 'new' => sub { |
17
|
|
|
|
|
|
|
my $orig = shift; |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $obj = $self->$orig( @_ ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
if ( not exists $object_cache{ $obj->address->ip } ) { |
23
|
|
|
|
|
|
|
Zonemaster::Engine->logger->add( CACHE_CREATED => { ip => $obj->address->ip } ); |
24
|
|
|
|
|
|
|
$object_cache{ $obj->address->ip } = $obj; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Zonemaster::Engine->logger->add( CACHE_FETCHED => { ip => $obj->address->ip } ); |
28
|
|
|
|
|
|
|
return $object_cache{ $obj->address->ip }; |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub empty_cache { |
32
|
2
|
|
|
2
|
1
|
34
|
%object_cache = (); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
5
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
26
|
|
|
26
|
|
171
|
no Moose; |
|
26
|
|
|
|
|
74
|
|
|
26
|
|
|
|
|
128
|
|
38
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Zonemaster::Engine::Nameserver::Cache - shared caches for nameserver objects |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 SYNOPSIS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This class should not be used directly. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item address |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
A L<Zonemaster::Engine::Net::IP> object holding the nameserver's address. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item data |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A reference to a hash holding the cache of sent queries. Not meant for external use. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=back |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 CLASS METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item empty_cache() |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Clear the cache. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |