| 1 | package Unblock::HTTP::_AltSvc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # A deliberately narrow Alt-Svc cache. It accepts h3 on the same hostname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # on a specified UDP port. Cross-host endpoints are not enabled yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 51 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=11 SCAR=26.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 51 | my ($class, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 51 | ▶ | my $clock = delete $option{clock} || sub { time }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Condition66%2/3
delete $option{'clock'} || sub {
time;
}
MC/DC0%0/2
delete $option{'clock'} || sub {
time;
}
delete $option{'clock'}
sub {
time;
}
Truth table66%2/3
A || B
A= delete $option{'clock'}B= sub {
time;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 51 | ▶ | croak 'alt_svc_clock must be a coderef' unless ref($clock) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 51 | ▶ | my $max_age = delete $option{max_age} || 86_400; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $option{'max_age'} || 86400
MC/DC100%1/1
delete $option{'max_age'} || 86400
delete $option{'max_age'}
Truth table100%2/2
A
A= delete $option{'max_age'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 51 | ▶ | my $max_entries = delete $option{max_entries} || 256; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $option{'max_entries'} || 256
MC/DC100%1/1
delete $option{'max_entries'} || 256
delete $option{'max_entries'}
Truth table100%2/2
A
A= delete $option{'max_entries'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 51 | for my $pair ([max_age => $max_age], [max_entries => $max_entries]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 102 | ▶ | croak "Alt-Svc $pair->[0] must be a positive integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $pair->[1] and not ref $pair->[1] and $pair->[1] =~ /\A[0-9]+\z/ and $pair->[1] > 0
defined $pair->[1] and not ref $pair->[1] and $pair->[1] =~ /\A[0-9]+\z/
defined $pair->[1] and not ref $pair->[1]
MC/DC0%0/4
defined $pair->[1] and not ref $pair->[1] and $pair->[1] =~ /\A[0-9]+\z/ and $pair->[1] > 0
defined $pair->[1]
not ref $pair->[1]
$pair->[1] =~ /\A[0-9]+\z/
$pair->[1] > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $pair->[1]B= not ref $pair->[1]C= $pair->[1] =~ /\A[0-9]+\z/D= $pair->[1] > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | unless defined($pair->[1]) && !ref($pair->[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | && $pair->[1] =~ /\A[0-9]+\z/ && $pair->[1] > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 51 | ▶ | croak 'unknown Alt-Svc option' if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 51 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | clock => $clock, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | max_age => $max_age, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | max_entries => $max_entries, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | entries => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 29 | ▶ | sub _elements { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_elements: called CC=12 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 29 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 29 | ▶ | return unless defined($value) && length($value) <= 4096; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $value and length $value <= 4096
MC/DC0%0/2
defined $value and length $value <= 4096
defined $value
length $value <= 4096
Truth table33%1/3
A and B
A= defined $valueB= length $value <= 4096
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 29 | my (@values, $part, $quote, $escaped) = ((), '', 0, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 29 | for my $char (split //, $value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 463 | ▶ | if ($escaped) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $part .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $escaped = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 463 | ▶ | if ($quote && $char eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$quote and $char eq "\\"
MC/DC0%0/2
$quote and $char eq "\\"
$quote
$char eq "\\"
Truth table66%2/3
A and B
A= $quoteB= $char eq "\\"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $part .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $escaped = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 463 | ▶ | if ($char eq '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 61 | $quote = !$quote; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 61 | $part .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 61 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 402 | ▶ | if (!$quote && $char eq ',') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $quote and $char eq ","
MC/DC100%2/2
not $quote and $char eq ","
not $quote
$char eq ","
Truth table100%3/3
not(A) and B
A= not $quoteB= $char eq ","
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | push @values, $part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | $part = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 399 | $part .= $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 29 | ▶ | return if $quote || $escaped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$quote or $escaped
MC/DC50%1/2
$quote or $escaped
$quote
$escaped
Truth table66%2/3
A or B
A= $quoteB= $escaped
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 28 | push @values, $part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 28 | return \@values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 39 | ▶ | sub _valid_age { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_age: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 39 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | ▶ | return unless defined($value) && $value =~ /\A(?:0|[1-9][0-9]*)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $value and $value =~ /\A(?:0|[1-9][0-9]*)\z/
MC/DC100%2/2
defined $value and $value =~ /\A(?:0|[1-9][0-9]*)\z/
defined $value
$value =~ /\A(?:0|[1-9][0-9]*)\z/
Truth table100%3/3
A and B
A= defined $valueB= $value =~ /\A(?:0|[1-9][0-9]*)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # Larger numbers can be treated as expired without numeric overflow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 12 | ▶ | return 2_147_483_647 if length($value) > 9; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 12 | return 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 35 | ▶ | sub observe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
observe: called CC=28 SCAR=33.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 35 | my ($self, $key, $response) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 35 | ▶ | return unless defined($key) && $response && $response->can('header_values'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $key and $response and $response->can("header_values")
defined $key and $response
MC/DC0%0/3
defined $key and $response and $response->can("header_values")
defined $key
$response
$response->can("header_values")
Truth table25%1/4
A and B and C
A= defined $keyB= $responseC= $response->can("header_values")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 35 | my $headers = $response->header_values('alt-svc'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 35 | ▶ | return unless $headers && @$headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$headers and @$headers
MC/DC50%1/2
$headers and @$headers
$headers
@$headers
Truth table66%2/3
A and B
A= $headersB= @$headers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 29 | my @elements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 29 | for my $value (@$headers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 29 | my $list = _elements($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 29 | ▶ | return unless $list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 28 | push @elements, @$list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # Any Alt-Svc response replaces prior origin alternatives. The clear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # directive takes precedence, even if the rest of the field is invalid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 28 | delete $self->{entries}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 28 | for my $element (@elements) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 115 | $element =~ s/\A[ \t]+|[ \t]+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 115 | ▶ | return if $element eq 'clear'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 26 | my $age = _valid_age($response->header('age')); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 26 | ▶ | $age = 0 unless defined $age; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 26 | my $now = $self->{clock}->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 26 | for my $element (@elements) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 106 | $element =~ s/\A[ \t]+|[ \t]+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 106 | ▶ | next unless $element =~ /\Ah3[ \t]*=[ \t]*":([0-9]+)"(.*)\z/s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 23 | my ($port, $params) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 23 | ▶ | next if length($port) > 5 || !$port || $port > 65535; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
length $port > 5 or not $port or $port > 65535
length $port > 5 or not $port
MC/DC100%3/3
length $port > 5 or not $port or $port > 65535
length $port > 5
not $port
$port > 65535
Truth table100%4/4
A or not(B) or C
A= length $port > 5B= not $portC= $port > 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 20 | my $ma = 86_400; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 20 | my $bad = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 20 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 20 | ▶ | while (length $params) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 16 | ▶ | if ($params =~ s/\A[ \t]*;[ \t]*([A-Za-z][A-Za-z0-9_-]*)[ \t]*=[ \t]*([A-Za-z0-9_-]+|"[^"]*")//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 15 | my ($name, $value) = (lc($1), $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 15 | ▶ | if ($name eq 'ma') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 13 | my $number = _valid_age($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 13 | ▶ | if ($seen{ma}++ || !defined $number) { $bad = 1; last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$seen{"ma"}++ or not defined $number
MC/DC100%2/2
$seen{"ma"}++ or not defined $number
$seen{"ma"}++
not defined $number
Truth table100%3/3
A or not(B)
A= $seen{"ma"}++B= not defined $number
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 9 | $ma = $number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 11 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | if ($params =~ /\A[ \t]*\z/) { $params = ''; last } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $bad = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 20 | ▶ | next if $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 15 | ▶ | $ma = $self->{max_age} if $ma > $self->{max_age}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 15 | ▶ | next if $ma <= $age; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # Limit memory even when an application visits many unique origins. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 14 | my $entries = $self->{entries}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 14 | for my $existing (keys %$entries) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | delete $entries->{$existing} if $entries->{$existing}{expires} <= $now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 14 | ▶ | if (keys(%$entries) >= $self->{max_entries}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | my ($oldest) = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | $entries->{$a}{expires} <=> $entries->{$b}{expires} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | } keys %$entries; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | delete $entries->{$oldest}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 14 | $entries->{$key} = { port => 0 + $port, expires => $now + $ma - $age }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 14 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 46 | ▶ | sub lookup { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 46 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 46 | ▶ | my $item = $self->{entries}{$key} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 18 | ▶ | if ($item->{expires} <= $self->{clock}->()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | delete $self->{entries}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 14 | return { %$item }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | ▶ | sub invalidate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invalidate: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | delete $self->{entries}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 10 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 10 | $self->{entries} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||