| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Algorithm::FloodControl::Backend::Cache::FastMmap; |
|
2
|
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
24059
|
use utf8; |
|
|
17
|
|
|
|
|
147
|
|
|
|
17
|
|
|
|
|
73
|
|
|
4
|
17
|
|
|
17
|
|
465
|
use strict; |
|
|
17
|
|
|
|
|
34
|
|
|
|
17
|
|
|
|
|
466
|
|
|
5
|
17
|
|
|
17
|
|
87
|
use warnings; |
|
|
17
|
|
|
|
|
18
|
|
|
|
17
|
|
|
|
|
522
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
12805
|
use Params::Validate qw/:all/; |
|
|
17
|
|
|
|
|
306771
|
|
|
|
17
|
|
|
|
|
4993
|
|
|
8
|
17
|
|
|
17
|
|
181
|
use base 'Algorithm::FloodControl::Backend'; |
|
|
17
|
|
|
|
|
50
|
|
|
|
17
|
|
|
|
|
10308
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw/storage prefix expires/ ); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head2 increment |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub increment { |
|
16
|
1558
|
|
|
1558
|
1
|
48255780
|
my ( $self ) = @_; |
|
17
|
|
|
|
|
|
|
my $last_value = $self->storage->get_and_set( |
|
18
|
|
|
|
|
|
|
$self->_tail_name, |
|
19
|
1558
|
|
100
|
1558
|
|
7263892
|
sub { $_[1] = ( $_[1] || 0 ) + 1 } |
|
20
|
1558
|
|
|
|
|
5082
|
); # If it does not exists |
|
21
|
1558
|
|
|
|
|
467458
|
$self->storage->set( $self->_item_name($last_value ) => time + $self->expires, $self->expires ); |
|
22
|
1558
|
|
|
|
|
705182
|
return 1; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 clear |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub clear { |
|
30
|
18
|
|
|
18
|
1
|
36
|
my ($self) = @_; |
|
31
|
18
|
|
|
|
|
86
|
return $self->storage->remove( $self->_tail_name ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 get_item |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub get_item { |
|
40
|
1681
|
|
|
1681
|
1
|
1759
|
my $self = shift; |
|
41
|
1681
|
|
|
|
|
2862
|
my $item = shift; |
|
42
|
1681
|
|
|
|
|
4449
|
return $self->storage->get( $self->_item_name($item) ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _last_number { |
|
46
|
87
|
|
|
87
|
|
193
|
my $self = shift; |
|
47
|
87
|
|
|
|
|
281
|
return $self->storage->get( $self->_tail_name ); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _tail_name { |
|
51
|
1663
|
|
|
1663
|
|
13763
|
my $self = shift; |
|
52
|
1663
|
|
|
|
|
6412
|
return $self->prefix . "_end"; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _item_name { |
|
56
|
3239
|
|
|
3239
|
|
20845
|
my $self = shift; |
|
57
|
3239
|
|
|
|
|
4384
|
my $item = shift; |
|
58
|
3239
|
|
|
|
|
9231
|
return $self->prefix . "_$item"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |