line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::FloodControl::Backend; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
104
|
use utf8; |
|
17
|
|
|
|
|
34
|
|
|
17
|
|
|
|
|
134
|
|
4
|
17
|
|
|
17
|
|
463
|
use strict; |
|
17
|
|
|
|
|
57
|
|
|
17
|
|
|
|
|
448
|
|
5
|
17
|
|
|
17
|
|
101
|
use warnings; |
|
17
|
|
|
|
|
34
|
|
|
17
|
|
|
|
|
524
|
|
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
101
|
use base 'Class::Accessor::Fast'; |
|
17
|
|
|
|
|
18
|
|
|
17
|
|
|
|
|
14271
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw/storage prefix expires/ ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head2 get_info |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub get_info { |
15
|
87
|
|
|
87
|
1
|
49781028
|
my $self = shift; |
16
|
87
|
|
|
|
|
210
|
my $attempts = shift; |
17
|
87
|
|
|
|
|
172
|
my $size = 0; |
18
|
87
|
|
|
|
|
414
|
my $number = $self->_last_number; |
19
|
87
|
100
|
|
|
|
15668
|
if ( ! defined $number ) { |
20
|
|
|
|
|
|
|
return { |
21
|
22
|
|
|
|
|
137
|
size => $size, |
22
|
|
|
|
|
|
|
timeout => 0 |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
} |
25
|
65
|
|
|
|
|
118
|
my $last_timeout; |
26
|
|
|
|
|
|
|
my $timeout; |
27
|
65
|
|
|
|
|
315
|
while ( defined ( $timeout = $self->get_item($number) ) ){ |
28
|
1616
|
50
|
66
|
|
|
93656
|
if ( ! $attempts || $size < $attempts ) { |
29
|
1616
|
|
|
|
|
1812
|
$last_timeout = $timeout; |
30
|
|
|
|
|
|
|
} |
31
|
1616
|
|
|
|
|
1541
|
$size++; |
32
|
1616
|
|
|
|
|
4203
|
$number--; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
return { |
35
|
65
|
50
|
|
|
|
4504
|
size => $size, |
36
|
|
|
|
|
|
|
timeout => $last_timeout ? $last_timeout - time : 0 |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |