FloodControl/Backend/Cache/Memcached.pm

filter: Statementstmt 45.7% 16 / 35 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 100% 3 / 3 totaltotal 47.0% 24 / 51 CC 2 SCAR 8.1
CC
2
Cov
43%
increment
6.0
clear
2.0
get_item
2.0
CRAP 2.2
« FloodControl/Backend.pm ↑ Summary FloodControl/Backend/Cache/FastMmap.pm »
1 package Algorithm::FloodControl::Backend::Cache::Memcached;
2  
3 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Params::Validate qw/:all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use base 'Algorithm::FloodControl::Backend';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head2 increment
11  
12 =cut
13  
14 0 ▶sub increment {
Subroutine increment: not called CC=2 SCAR=17.9
Pod documented
15 0 my ( $self ) = @_;
16 0 my $is_added = $self->storage->add( $self->_tail_name, 0 ); # If it does not exists
17 0 my $last_value = 0;
18 0 ▶ if ( ! $is_added ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_added) 0 0 0
19 0 $last_value = $self->storage->incr( $self->_tail_name );
20 }
21 0 $self->storage->set( $self->_item_name($last_value) => time + $self->expires, $self->expires );
22 0 return $last_value;
23 }
24  
25 =head2 clear
26  
27 =cut
28  
29 0 ▶sub clear {
Subroutine clear: not called CC=1 SCAR=6.9
Pod documented
30 0 my ($self) = @_;
31 0 return $self->storage->delete( $self->_tail_name );
32 }
33  
34 =head2 get_item
35  
36 =cut
37  
38 0 ▶sub get_item {
Subroutine get_item: not called CC=1 SCAR=6.9
Pod documented
39 0 my $self = shift;
40 0 my $item = shift;
41 0 return $self->storage->get( $self->_item_name($item) );
42 }
43  
44 0 ▶sub _last_number {
Subroutine _last_number: not called CC=1 SCAR=6.9
45 0 my $self = shift;
46 0 return $self->storage->get( $self->_tail_name );
47 }
48  
49 0 ▶sub _tail_name {
Subroutine _tail_name: not called CC=1 SCAR=6.9
50 0 my $self = shift;
51 0 return $self->prefix . "_end";
52 }
53  
54 0 ▶sub _item_name {
Subroutine _item_name: not called CC=1 SCAR=6.9
55 0 my $self = shift;
56 0 my $item = shift;
57 0 return $self->prefix . "_$item";
58 }
59  
60 1 1;
61  
62  
63 __END__
« FloodControl/Backend.pm ↑ Summary FloodControl/Backend/Cache/FastMmap.pm »