Zonemaster/Nameserver/Cache.pm

filter: Statementstmt 64.5% 20 / 31 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 100% 1 / 1 totaltotal 61.9% 26 / 42 CC 2 SCAR 8.0
CC
2
Cov
61%
__ANON__
6.0
empty_cache
2.0
__ANON__
1.1
CRAP 2.2
« Zonemaster/Translator.pm ↑ Summary Zonemaster/Constants.pm »
1 package Zonemaster::Nameserver::Cache v1.0.0;
2  
3 1 ▶use 5.14.2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Zonemaster;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our %object_cache;
9  
10 0 ▶has 'data' => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
11 1 has 'address' => ( is => 'ro', isa => 'Net::IP::XS', required => 1 );
12  
13 around 'new' => sub {
14 0 ▶ my $orig = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
15 0 my $self = shift;
16  
17 0 my $obj = $self->$orig( @_ );
18  
19 0 ▶ if ( not exists $object_cache{ $obj->address->ip } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Zonemaster::Nameserver::Cache::object_cache{$obj->address->ip}) 0 0 0
20 0 Zonemaster->logger->add( CACHE_CREATED => { ip => $obj->address->ip } );
21 0 $object_cache{ $obj->address->ip } = $obj;
22 }
23  
24 0 Zonemaster->logger->add( CACHE_FETCHED => { ip => $obj->address->ip } );
25 0 return $object_cache{ $obj->address->ip };
26 1 };
27  
28 sub empty_cache {
29 0 ▶ %object_cache = ();
Subroutine empty_cache: not called CC=1 SCAR=6.9
Pod documented
30  
31 0 return;
32 }
33  
34 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
36  
37 1 1;
38  
39 =head1 NAME
40  
41 Zonemaster::Nameserver::Cache - shared caches for nameserver objects
42  
43 =head1 SYNOPSIS
44  
45 This class should not be used directly.
46  
47 =head1 ATTRIBUTES
48  
49 =over
50  
51 =item address
52  
53 A L<Net::IP::XS> object holding the nameserver's address.
54  
55 =item data
56  
57 A reference to a hash holding the cache of sent queries. Not meant for external use.
58  
59 =back
60  
61 =head1 CLASS METHODS
62  
63 =over
64  
65 =item empty_cache()
66  
67 Clear the cache.
68  
69 =back
70  
71 =cut
« Zonemaster/Translator.pm ↑ Summary Zonemaster/Constants.pm »