Alzabo/Runtime/UniqueRowCache.pm

filter: Statementstmt 46.6% 14 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 100% 5 / 5 totaltotal 45.1% 23 / 51 CC 4 SCAR 19.8
CC
4
Cov
39%
__ANON__
20.0
clear
2.0
clear_table
2.0
CRAP 7.3
« Alzabo/Index.pm ↑ Summary Alzabo/Debug.pm »
1 package Alzabo::Runtime::UniqueRowCache;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Alzabo::Runtime::Table;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Alzabo::Runtime::RowState::InCache;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 my %CACHE;
9  
10 BEGIN
11 2 ▶{
Subroutine BEGIN: called CC=1 SCAR=4.8
12 2 my $real_make_row = \&Alzabo::Runtime::Table::_make_row;
13  
14 2 local $^W = 0;
15 *Alzabo::Runtime::Table::_make_row =
16 0 ▶ sub { my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
17 0 my %p = @_;
18  
19 0 ▶ if ( delete $p{no_cache} )
Branch: 1 branch
BranchTrueFalseTotal
if (delete $p{"no_cache"}) 0 0 0
20 {
21 return
22 0 $self->$real_make_row( %p,
23 state => 'Alzabo::Runtime::RowState::Live',
24 );
25 }
26  
27 my $id =
28 Alzabo::Runtime::Row->id_as_string_ext
29 ( pk => $p{pk},
30 table => $p{table},
31 0 );
32  
33 0 my $table_name = $p{table}->name;
34 0 ▶ return $CACHE{$table_name}{$id} if exists $CACHE{$table_name}{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $CACHE{$table_name}{$id} 0 0 0
35  
36 0 my $row =
37 $self->$real_make_row( %p,
38 state => 'Alzabo::Runtime::RowState::InCache',
39 );
40  
41 0 ▶ return unless $row;
Branch: 1 branch
BranchTrueFalseTotal
unless $row 0 0 0
42  
43 0 Alzabo::Runtime::UniqueRowCache->write_to_cache($row);
44  
45 0 return $row;
46 2 };
47 }
48  
49 0 ▶sub clear { %CACHE = () };
Subroutine clear: not called CC=1 SCAR=6.9
Pod documented
50  
51 0 ▶sub clear_table { delete $CACHE{ $_[1]->name } }
Subroutine clear_table: not called CC=1 SCAR=6.9
Pod documented
52  
53 0 ▶sub row_in_cache { return $CACHE{ $_[1] }{ $_[2] } }
Subroutine row_in_cache: not called CC=1 SCAR=6.9
Pod documented
54  
55 0 ▶sub delete_from_cache { delete $CACHE{ $_[1] }{ $_[2] } }
Subroutine delete_from_cache: not called CC=1 SCAR=6.9
Pod documented
56  
57 0 ▶sub write_to_cache { $CACHE{ $_[1]->table->name }{ $_[1]->id_as_string } = $_[1] }
Subroutine write_to_cache: not called CC=1 SCAR=6.9
Pod documented
58  
59 2 1;
60  
61 __END__
« Alzabo/Index.pm ↑ Summary Alzabo/Debug.pm »