MemoryBackend.pm

filter: Statementstmt 89.4% 34 / 38 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 8 totaltotal 72.0% 49 / 68 SCAR 14.1
CC
4
Cov
82%
_initialize_memory_backend
2.3
get_size
2.1
new
2.0
CRAP 4.1
« MemoryCache.pm ↑ Summary BaseCacheTester.pm »
1 ######################################################################
2 # $Id: MemoryBackend.pm,v 1.10 2003/01/16 18:10:16 dclinton Exp $
3 # Copyright (C) 2001-2003 DeWitt Clinton All Rights Reserved
4 #
5 # Software distributed under the License is distributed on an "AS
6 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or
7 # implied. See the License for the specific language governing
8 # rights and limitations under the License.
9 ######################################################################
10  
11 package Cache::MemoryBackend;
12  
13 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Cache::CacheUtils qw( Clone_Data );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 2 my $Store_Ref = { };
18  
19  
20 sub new
21 {
22 68 ▶ my ( $proto ) = @_;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
23 68 ▶ my $class = ref( $proto ) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0680
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
24 68 my $self = {};
25 68 $self = bless( $self, $class );
26 68 $self->_initialize_memory_backend( );
27 68 return $self;
28 }
29  
30  
31 sub delete_key
32 {
33 27 ▶ my ( $self, $p_namespace, $p_key ) = @_;
Subroutine delete_key: called CC=1 SCAR=0.0
Pod undocumented
34  
35 27 delete $self->_get_store_ref( )->{ $p_namespace }{ $p_key };
36 }
37  
38  
39 sub delete_namespace
40 {
41 25 ▶ my ( $self, $p_namespace ) = @_;
Subroutine delete_namespace: called CC=1 SCAR=0.0
Pod undocumented
42  
43 25 delete $self->_get_store_ref( )->{ $p_namespace };
44 }
45  
46  
47 sub get_keys
48 {
49 47 ▶ my ( $self, $p_namespace ) = @_;
Subroutine get_keys: called CC=1 SCAR=0.0
Pod undocumented
50  
51 47 return keys %{ $self->_get_store_ref( )->{ $p_namespace } };
52 }
53  
54  
55 sub get_namespaces
56 {
57 36 ▶ my ( $self ) = @_;
Subroutine get_namespaces: called CC=1 SCAR=0.0
Pod undocumented
58  
59 36 return keys %{ $self->_get_store_ref( ) };
60 }
61  
62  
63 sub get_size
64 {
65 119 ▶ my ( $self, $p_namespace, $p_key ) = @_;
Subroutine get_size: called CC=2 SCAR=7.6
Pod undocumented
66  
67 119 ▶ if ( exists $self->_get_store_ref( )->{ $p_namespace }{ $p_key } )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->_get_store_ref->{$p_namespace}{$p_key}) { } 119 0 119
68 {
69 119 return length $self->_get_store_ref( )->{ $p_namespace }{ $p_key };
70 }
71 else
72 {
73 0 return 0;
74 }
75 }
76  
77  
78 sub restore
79 {
80 122 ▶ my ( $self, $p_namespace, $p_key ) = @_;
Subroutine restore: called CC=1 SCAR=0.0
Pod undocumented
81  
82 122 return Clone_Data( $self->_get_store_ref( )->{ $p_namespace }{ $p_key } );
83 }
84  
85  
86 sub store
87 {
88 90 ▶ my ( $self, $p_namespace, $p_key, $p_data ) = @_;
Subroutine store: called CC=1 SCAR=0.0
Pod undocumented
89  
90 90 $self->_get_store_ref( )->{ $p_namespace }{ $p_key } = $p_data;
91 }
92  
93  
94 sub _initialize_memory_backend
95 {
96 68 ▶ my ( $self ) = @_;
Subroutine _initialize_memory_backend: called CC=2 SCAR=8.1
97  
98 68 ▶ if ( not defined $self->_get_store_ref( ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->_get_store_ref) 0 68 68
99 {
100 0 $self->_set_store_ref( { } );
101 }
102 }
103  
104  
105 sub _get_store_ref
106 {
107 653 ▶ return $Store_Ref;
Subroutine _get_store_ref: called CC=1 SCAR=0.0
108 }
109  
110  
111 sub _set_store_ref
112 {
113 0 ▶ my ( $self, $p_store_ref ) = @_;
Subroutine _set_store_ref: not called CC=1 SCAR=6.9
114  
115 0 $Store_Ref = $p_store_ref;
116 }
117  
118  
119  
120 2 1;
121  
122 __END__
« MemoryCache.pm ↑ Summary BaseCacheTester.pm »