BaseCache.pm

filter: Statementstmt 95.6% 197 / 206 Branchbran 79.5% 35 / 44 Conditioncond 33.3% 5 / 15 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 98.1% 53 / 54 Podpod 48.0% 12 / 25 totaltotal 85.5% 303 / 354 SCAR 34.4
CC
30
Cov
89%
Canonicalize_Expiration_Time
12.7
Object_Has_Expired
6.3
get
4.0
CRAP 31.1
« CacheTester.pm ↑ Summary SizeAwareCacheTester.pm »
1 ######################################################################
2 # $Id: BaseCache.pm,v 1.25 2003/04/15 14:46:14 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  
12 package Cache::BaseCache;
13  
14  
15 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Cache::Cache qw( $EXPIRES_NEVER $EXPIRES_NOW );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use Cache::CacheUtils qw( Assert_Defined Clone_Data );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Cache::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 4 @ISA = qw( Cache::Cache );
24  
25  
26 4 my $DEFAULT_EXPIRES_IN = $EXPIRES_NEVER;
27 4 my $DEFAULT_NAMESPACE = "Default";
28 4 my $DEFAULT_AUTO_PURGE_ON_SET = 0;
29 4 my $DEFAULT_AUTO_PURGE_ON_GET = 0;
30  
31  
32 # namespace that stores the keys used for the auto purge functionality
33  
34 4 my $AUTO_PURGE_NAMESPACE = "__AUTO_PURGE__";
35  
36  
37 # map of expiration formats to their respective time in seconds
38  
39 4 my %_Expiration_Units = ( map(($_, 1), qw(s second seconds sec)),
40 map(($_, 60), qw(m minute minutes min)),
41 map(($_, 60*60), qw(h hour hours)),
42 map(($_, 60*60*24), qw(d day days)),
43 map(($_, 60*60*24*7), qw(w week weeks)),
44 map(($_, 60*60*24*30), qw(M month months)),
45 map(($_, 60*60*24*365), qw(y year years)) );
46  
47  
48  
49 # Takes the time the object was created, the default_expires_in and
50 # optionally the explicitly set expires_in and returns the time the
51 # object will expire. Calls _canonicalize_expiration to convert
52 # strings like "5m" into second values.
53  
54 sub Build_Expires_At
55 {
56 134 ▶ my ( $p_created_at, $p_default_expires_in, $p_explicit_expires_in ) = @_;
Subroutine Build_Expires_At: called CC=2 SCAR=6.9
Pod undocumented
57  
58 134 ▶ my $expires_in = defined $p_explicit_expires_in ?
Branch: 1 branch
BranchTrueFalseTotal
defined $p_explicit_expires_in ? : 40 94 134
59 $p_explicit_expires_in : $p_default_expires_in;
60  
61 134 return Sum_Expiration_Time( $p_created_at, $expires_in );
62 }
63  
64  
65 # Return a Cache::Object object
66  
67 sub Build_Object
68 {
69 134 ▶ my ( $p_key, $p_data, $p_default_expires_in, $p_expires_in ) = @_;
Subroutine Build_Object: called CC=1 SCAR=0.0
Pod undocumented
70  
71 134 Assert_Defined( $p_key );
72 134 Assert_Defined( $p_default_expires_in );
73  
74 134 my $now = time( );
75  
76 134 my $object = new Cache::Object( );
77  
78 134 $object->set_key( $p_key );
79 134 $object->set_data( $p_data );
80 134 $object->set_created_at( $now );
81 134 $object->set_accessed_at( $now );
82 134 $object->set_expires_at( Build_Expires_At( $now,
83 $p_default_expires_in,
84 $p_expires_in ) );
85 134 return $object;
86 }
87  
88  
89 # Compare the expires_at to the current time to determine whether or
90 # not an object has expired (the time parameter is optional)
91  
92 sub Object_Has_Expired
93 {
94 122 ▶ my ( $p_object, $p_time ) = @_;
Subroutine Object_Has_Expired: called CC=6 SCAR=18.4
Pod undocumented
95  
96 122 ▶ if ( not defined $p_object )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $p_object) 6 116 122
97 {
98 6 return 1;
99 }
100  
101 116 ▶ $p_time = $p_time || time( );
Condition33%1/3
$p_time || time
l!l&&r!l&&!r
01160
MC/DC0%0/2
$p_time || time
$p_time time
Truth table33%1/3
A || B
A= $p_timeB= time
ABresult
1X1
011
000
102  
103 116 ▶ if ( $p_object->get_expires_at( ) eq $EXPIRES_NOW )
Branch: 3 branches
BranchTrueFalseTotal
if ($p_object->get_expires_at eq $Cache::BaseCache::EXPIRES_NOW) { } 0 116 116
elsif ($p_object->get_expires_at eq $Cache::BaseCache::EXPIRES_NEVER) { } 24 92 116
elsif ($p_time >= $p_object->get_expires_at) { } 40 52 92
104 {
105 0 return 1;
106 }
107 elsif ( $p_object->get_expires_at( ) eq $EXPIRES_NEVER )
108 {
109 24 return 0;
110 }
111 elsif ( $p_time >= $p_object->get_expires_at( ) )
112 {
113 40 return 1;
114 }
115 else
116 {
117 52 return 0;
118 }
119 }
120  
121  
122 # Returns the sum of the base created_at time (in seconds since the epoch)
123 # and the canonical form of the expires_at string
124  
125  
126 sub Sum_Expiration_Time
127 {
128 134 ▶ my ( $p_created_at, $p_expires_in ) = @_;
Subroutine Sum_Expiration_Time: called CC=2 SCAR=6.9
Pod undocumented
129  
130 134 Assert_Defined( $p_created_at );
131 134 Assert_Defined( $p_expires_in );
132  
133 134 ▶ if ( $p_expires_in eq $EXPIRES_NEVER )
Branch: 1 branch
BranchTrueFalseTotal
if ($p_expires_in eq $Cache::BaseCache::EXPIRES_NEVER) { } 72 62 134
134 {
135 72 return $EXPIRES_NEVER;
136 }
137 else
138 {
139 62 return $p_created_at + Canonicalize_Expiration_Time( $p_expires_in );
140 }
141 }
142  
143  
144 # turn a string in the form "[number] [unit]" into an explicit number
145 # of seconds from the present. E.g, "10 minutes" returns "600"
146  
147 sub Canonicalize_Expiration_Time
148 {
149 62 ▶ my ( $p_expires_in ) = @_;
Subroutine Canonicalize_Expiration_Time: called CC=6 SCAR=25.4
Pod undocumented
150  
151 62 Assert_Defined( $p_expires_in );
152  
153 62 my $secs;
154  
155 62 ▶ if ( uc( $p_expires_in ) eq uc( $EXPIRES_NOW ) )
Branch: 4 branches
BranchTrueFalseTotal
if (uc $p_expires_in eq uc $Cache::BaseCache::EXPIRES_NOW) { } 0 62 62
elsif (uc $p_expires_in eq uc $Cache::BaseCache::EXPIRES_NEVER) { } 0 62 62
elsif ($p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*$/) { } 62 0 62
elsif ($p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*(\w*)\s*$/ and exists $_Expiration_Units{$2}) { } 0 0 0
156 {
157 0 $secs = 0;
158 }
159 elsif ( uc( $p_expires_in ) eq uc( $EXPIRES_NEVER ) )
160 {
161 0 throw Error::Simple( "Internal error. expires_in eq $EXPIRES_NEVER" );
162 }
163 elsif ( $p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*$/ )
164 {
165 62 $secs = $p_expires_in;
166 }
167 ▶ elsif ( $p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*(\w*)\s*$/
Condition0%0/3
$p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*(\w*)\s*$/ and exists $_Expiration_Units{$2}
!ll&&!rl&&r
000
MC/DC0%0/2
$p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*(\w*)\s*$/ and exists $_Expiration_Units{$2}
$p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*(\w*)\s*$/ exists $_Expiration_Units{$2}
Truth table0%0/3
A and B
A= $p_expires_in =~ /^\s*([+-]?(?:\d+|\d*\.\d*))\s*(\w*)\s*$/B= exists $_Expiration_Units{$2}
ABresult
0X0
100
111
168 and exists( $_Expiration_Units{ $2 } ))
169 {
170 0 $secs = ( $_Expiration_Units{ $2 } ) * $1;
171 }
172 else
173 {
174 0 throw Error::Simple( "invalid expiration time '$p_expires_in'" );
175 }
176  
177 62 return $secs;
178 }
179  
180  
181  
182 sub clear
183 {
184 32 ▶ my ( $self ) = @_;
Subroutine clear: called CC=1 SCAR=0.0
Pod documented
185  
186 32 $self->_get_backend( )->delete_namespace( $self->get_namespace( ) );
187 }
188  
189  
190 sub get
191 {
192 110 ▶ my ( $self, $p_key ) = @_;
Subroutine get: called CC=4 SCAR=13.9
Pod documented
193  
194 110 Assert_Defined( $p_key );
195  
196 110 ▶ $self->_conditionally_auto_purge_on_get( ) unless
Branch: 1 branch
BranchTrueFalseTotal
unless $self->get_namespace eq $AUTO_PURGE_NAMESPACE 88 22 110
197 $self->get_namespace( ) eq $AUTO_PURGE_NAMESPACE;
198  
199 110 ▶ my $object = $self->get_object( $p_key ) or
Branch: 1 branch
BranchTrueFalseTotal
my $object = $self->get_object($p_key) or return undef 28 82 110
200 return undef;
201  
202 82 ▶ if ( Object_Has_Expired( $object ) )
Branch: 1 branch
BranchTrueFalseTotal
if (Object_Has_Expired($object)) 32 50 82
203 {
204 32 $self->remove( $p_key );
205 32 return undef;
206 }
207  
208 50 return $object->get_data( );
209 }
210  
211  
212 sub get_keys
213 {
214 94 ▶ my ( $self ) = @_;
Subroutine get_keys: called CC=1 SCAR=0.0
Pod documented
215  
216 94 return $self->_get_backend( )->get_keys( $self->get_namespace( ) );
217 }
218  
219  
220 sub get_identifiers
221 {
222 0 ▶ my ( $self ) = @_;
Subroutine get_identifiers: not called CC=1 SCAR=6.9
Pod documented
223  
224 0 warn( "get_identifiers has been marked deprepricated. use get_keys" );
225  
226 0 return $self->get_keys( );
227 }
228  
229  
230 sub get_object
231 {
232 244 ▶ my ( $self, $p_key ) = @_;
Subroutine get_object: called CC=2 SCAR=6.9
Pod documented
233  
234 244 Assert_Defined( $p_key );
235  
236 244 ▶ my $object =
Branch: 1 branch
BranchTrueFalseTotal
my $object = $self->_get_backend->restore($self->get_namespace, $p_key) or return undef 62 182 244
237 $self->_get_backend( )->restore( $self->get_namespace( ), $p_key ) or
238 return undef;
239  
240 182 $object->set_size( $self->_get_backend( )->
241 get_size( $self->get_namespace( ), $p_key ) );
242  
243 182 $object->set_key( $p_key );
244  
245 182 return $object;
246 }
247  
248  
249 sub purge
250 {
251 26 ▶ my ( $self ) = @_;
Subroutine purge: called CC=2 SCAR=6.9
Pod documented
252  
253 26 foreach my $key ( $self->get_keys( ) )
254 {
255 28 $self->get( $key );
256 }
257 }
258  
259  
260 sub remove
261 {
262 54 ▶ my ( $self, $p_key ) = @_;
Subroutine remove: called CC=1 SCAR=0.0
Pod documented
263  
264 54 Assert_Defined( $p_key );
265  
266 54 $self->_get_backend( )->delete_key( $self->get_namespace( ), $p_key );
267 }
268  
269  
270 sub set
271 {
272 112 ▶ my ( $self, $p_key, $p_data, $p_expires_in ) = @_;
Subroutine set: called CC=1 SCAR=0.0
Pod documented
273  
274 112 Assert_Defined( $p_key );
275  
276 112 $self->_conditionally_auto_purge_on_set( );
277  
278 112 $self->set_object( $p_key,
279 Build_Object( $p_key,
280 $p_data,
281 $self->get_default_expires_in( ),
282 $p_expires_in ) );
283 }
284  
285  
286 sub set_object
287 {
288 180 ▶ my ( $self, $p_key, $p_object ) = @_;
Subroutine set_object: called CC=1 SCAR=0.0
Pod documented
289  
290 180 my $object = Clone_Data( $p_object );
291  
292 180 $object->set_size( undef );
293 180 $object->set_key( undef );
294  
295 180 $self->_get_backend( )->store( $self->get_namespace( ), $p_key, $object );
296 }
297  
298  
299 sub size
300 {
301 58 ▶ my ( $self ) = @_;
Subroutine size: called CC=2 SCAR=6.9
Pod documented
302  
303 58 my $size = 0;
304  
305 58 foreach my $key ( $self->get_keys( ) )
306 {
307 56 $size += $self->_get_backend( )->get_size( $self->get_namespace( ), $key );
308 }
309  
310 58 return $size;
311 }
312  
313  
314 sub get_namespaces
315 {
316 4 ▶ my ( $self ) = @_;
Subroutine get_namespaces: called CC=1 SCAR=0.0
Pod documented
317  
318 4 return grep {!/$AUTO_PURGE_NAMESPACE/} $self->_get_backend( )->get_namespaces( );
319 }
320  
321  
322 sub _new
323 {
324 50 ▶ my ( $proto, $p_options_hash_ref ) = @_;
Subroutine _new: called CC=2 SCAR=7.1
325 50 ▶ my $class = ref( $proto ) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0500
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
326 50 my $self = {};
327 50 bless( $self, $class );
328 50 $self->_initialize_base_cache( $p_options_hash_ref );
329 50 return $self;
330 }
331  
332  
333 sub _complete_initialization
334 {
335 50 ▶ my ( $self ) = @_;
Subroutine _complete_initialization: called CC=1 SCAR=0.0
336 50 $self->_initialize_auto_purge_interval( );
337 }
338  
339  
340 sub _initialize_base_cache
341 {
342 50 ▶ my ( $self, $p_options_hash_ref ) = @_;
Subroutine _initialize_base_cache: called CC=1 SCAR=0.0
343  
344 50 $self->_initialize_options_hash_ref( $p_options_hash_ref );
345 50 $self->_initialize_namespace( );
346 50 $self->_initialize_default_expires_in( );
347 50 $self->_initialize_auto_purge_on_set( );
348 50 $self->_initialize_auto_purge_on_get( );
349 }
350  
351  
352 sub _initialize_options_hash_ref
353 {
354 50 ▶ my ( $self, $p_options_hash_ref ) = @_;
Subroutine _initialize_options_hash_ref: called CC=2 SCAR=6.9
355  
356 50 ▶ $self->_set_options_hash_ref( defined $p_options_hash_ref ?
Branch: 1 branch
BranchTrueFalseTotal
defined $p_options_hash_ref ? : 42 8 50
357 $p_options_hash_ref :
358 { } );
359 }
360  
361  
362 sub _initialize_namespace
363 {
364 50 ▶ my ( $self ) = @_;
Subroutine _initialize_namespace: called CC=1 SCAR=0.0
365  
366 50 my $namespace = $self->_read_option( 'namespace', $DEFAULT_NAMESPACE );
367  
368 50 $self->set_namespace( $namespace );
369 }
370  
371  
372 sub _initialize_default_expires_in
373 {
374 50 ▶ my ( $self ) = @_;
Subroutine _initialize_default_expires_in: called CC=1 SCAR=0.0
375  
376 50 my $default_expires_in =
377 $self->_read_option( 'default_expires_in', $DEFAULT_EXPIRES_IN );
378  
379 50 $self->_set_default_expires_in( $default_expires_in );
380 }
381  
382  
383 sub _initialize_auto_purge_interval
384 {
385 50 ▶ my ( $self ) = @_;
Subroutine _initialize_auto_purge_interval: called CC=2 SCAR=6.9
386  
387 50 my $auto_purge_interval = $self->_read_option( 'auto_purge_interval' );
388  
389 50 ▶ if ( defined $auto_purge_interval )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $auto_purge_interval) 4 46 50
390 {
391 4 $self->set_auto_purge_interval( $auto_purge_interval );
392 4 $self->_auto_purge( );
393 }
394 }
395  
396  
397 sub _initialize_auto_purge_on_set
398 {
399 50 ▶ my ( $self ) = @_;
Subroutine _initialize_auto_purge_on_set: called CC=1 SCAR=0.0
400  
401 50 my $auto_purge_on_set =
402 $self->_read_option( 'auto_purge_on_set', $DEFAULT_AUTO_PURGE_ON_SET );
403  
404 50 $self->set_auto_purge_on_set( $auto_purge_on_set );
405 }
406  
407  
408 sub _initialize_auto_purge_on_get
409 {
410 50 ▶ my ( $self ) = @_;
Subroutine _initialize_auto_purge_on_get: called CC=1 SCAR=0.0
411  
412 50 my $auto_purge_on_get =
413 $self->_read_option( 'auto_purge_on_get', $DEFAULT_AUTO_PURGE_ON_GET );
414  
415 50 $self->set_auto_purge_on_get( $auto_purge_on_get );
416 }
417  
418  
419  
420 # _read_option looks for an option named 'option_name' in the
421 # option_hash associated with this instance. If it is not found, then
422 # 'default_value' will be returned instead
423  
424 sub _read_option
425 {
426 358 ▶ my ( $self, $p_option_name, $p_default_value ) = @_;
Subroutine _read_option: called CC=2 SCAR=6.9
427  
428 358 my $options_hash_ref = $self->_get_options_hash_ref( );
429  
430 358 ▶ if ( defined $options_hash_ref->{ $p_option_name } )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options_hash_ref->{$p_option_name}) { } 42 316 358
431 {
432 42 return $options_hash_ref->{ $p_option_name };
433 }
434 else
435 {
436 316 return $p_default_value;
437 }
438 }
439  
440  
441  
442 # this method checks to see if the auto_purge property is set for a
443 # particular cache. If it is, then it switches the cache to the
444 # $AUTO_PURGE_NAMESPACE and stores that value under the name of the
445 # current cache namespace
446  
447 sub _reset_auto_purge_interval
448 {
449 22 ▶ my ( $self ) = @_;
Subroutine _reset_auto_purge_interval: called CC=3 SCAR=11.2
450  
451 22 ▶ return if not $self->_should_auto_purge( );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_should_auto_purge 0 22 22
452  
453 22 my $real_namespace = $self->get_namespace( );
454  
455 22 $self->set_namespace( $AUTO_PURGE_NAMESPACE );
456  
457 22 ▶ if ( not defined $self->get( $real_namespace ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->get($real_namespace)) 22 0 22
458 {
459 22 $self->_insert_auto_purge_object( $real_namespace );
460 }
461  
462 22 $self->set_namespace( $real_namespace );
463 }
464  
465  
466 sub _should_auto_purge
467 {
468 62 ▶ my ( $self ) = @_;
Subroutine _should_auto_purge: called CC=2 SCAR=8.1
469  
470 62 ▶ return ( defined $self->get_auto_purge_interval( ) &&
Condition33%1/3
defined $self->get_auto_purge_interval && $self->get_auto_purge_interval ne $Cache::BaseCache::EXPIRES_NEVER
!ll&&!rl&&r
0062
MC/DC0%0/2
defined $self->get_auto_purge_interval && $self->get_auto_purge_interval ne $Cache::BaseCache::EXPIRES_NEVER
defined $self->get_auto_purge_interval $self->get_auto_purge_interval ne $Cache::BaseCache::EXPIRES_NEVER
Truth table33%1/3
A && B
A= defined $self->get_auto_purge_intervalB= $self->get_auto_purge_interval ne $Cache::BaseCache::EXPIRES_NEVER
ABresult
0X0
100
111
471 $self->get_auto_purge_interval( ) ne $EXPIRES_NEVER );
472 }
473  
474 sub _insert_auto_purge_object
475 {
476 22 ▶ my ( $self, $p_real_namespace ) = @_;
Subroutine _insert_auto_purge_object: called CC=1 SCAR=0.0
477  
478 22 my $object = Build_Object( $p_real_namespace,
479 1,
480 $self->get_auto_purge_interval( ),
481 undef );
482  
483 22 $self->set_object( $p_real_namespace, $object );
484 }
485  
486  
487  
488 # this method checks to see if the auto_purge property is set, and if
489 # it is, switches to the $AUTO_PURGE_NAMESPACE and sees if a value
490 # exists at the location specified by a key named for the current
491 # namespace. If that key doesn't exist, then the purge method is
492 # called on the cache
493  
494 sub _auto_purge
495 {
496 40 ▶ my ( $self ) = @_;
Subroutine _auto_purge: called CC=2 SCAR=6.9
497  
498 40 ▶ if ( $self->_needs_auto_purge( ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_needs_auto_purge) 14 26 40
499 {
500 14 $self->purge( );
501 14 $self->_reset_auto_purge_interval( );
502 }
503 }
504  
505  
506 sub _get_auto_purge_object
507 {
508 40 ▶ my ( $self ) = @_;
Subroutine _get_auto_purge_object: called CC=1 SCAR=0.0
509  
510 40 my $real_namespace = $self->get_namespace( );
511 40 $self->set_namespace( $AUTO_PURGE_NAMESPACE );
512 40 my $auto_purge_object = $self->get_object( $real_namespace );
513 40 $self->set_namespace( $real_namespace );
514 40 return $auto_purge_object;
515 }
516  
517  
518 sub _needs_auto_purge
519 {
520 40 ▶ my ( $self ) = @_;
Subroutine _needs_auto_purge: called CC=2 SCAR=7.1
521  
522 40 ▶ return ( $self->_should_auto_purge( ) &&
Condition66%2/3
$self->_should_auto_purge && Object_Has_Expired($self->_get_auto_purge_object)
!ll&&!rl&&r
02614
MC/DC50%1/2
$self->_should_auto_purge && Object_Has_Expired($self->_get_auto_purge_object)
$self->_should_auto_purge Object_Has_Expired($self->_get_auto_purge_object)
Truth table66%2/3
A && B
A= $self->_should_auto_purgeB= Object_Has_Expired($self->_get_auto_purge_object)
ABresult
0X0
100
111
523 Object_Has_Expired( $self->_get_auto_purge_object( ) ) );
524 }
525  
526  
527 # call auto_purge if the auto_purge_on_set option is true
528  
529 sub _conditionally_auto_purge_on_set
530 {
531 112 ▶ my ( $self ) = @_;
Subroutine _conditionally_auto_purge_on_set: called CC=2 SCAR=6.9
532  
533 112 ▶ if ( $self->get_auto_purge_on_set( ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_auto_purge_on_set) 36 76 112
534 {
535 36 $self->_auto_purge( );
536 }
537 }
538  
539  
540 # call auto_purge if the auto_purge_on_get option is true
541  
542 sub _conditionally_auto_purge_on_get
543 {
544 88 ▶ my ( $self ) = @_;
Subroutine _conditionally_auto_purge_on_get: called CC=2 SCAR=8.1
545  
546 88 ▶ if ( $self->get_auto_purge_on_get( ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_auto_purge_on_get) 0 88 88
547 {
548 0 $self->_auto_purge( );
549 }
550 }
551  
552  
553 sub _get_options_hash_ref
554 {
555 358 ▶ my ( $self ) = @_;
Subroutine _get_options_hash_ref: called CC=1 SCAR=0.0
556  
557 358 return $self->{_Options_Hash_Ref};
558 }
559  
560  
561 sub _set_options_hash_ref
562 {
563 50 ▶ my ( $self, $options_hash_ref ) = @_;
Subroutine _set_options_hash_ref: called CC=1 SCAR=0.0
564  
565 50 $self->{_Options_Hash_Ref} = $options_hash_ref;
566 }
567  
568  
569 sub get_namespace
570 {
571 1014 ▶ my ( $self ) = @_;
Subroutine get_namespace: called CC=1 SCAR=0.0
Pod undocumented
572  
573 1014 return $self->{_Namespace};
574 }
575  
576  
577 sub set_namespace
578 {
579 178 ▶ my ( $self, $namespace ) = @_;
Subroutine set_namespace: called CC=1 SCAR=0.0
Pod undocumented
580  
581 178 $self->{_Namespace} = $namespace;
582 }
583  
584  
585 sub get_default_expires_in
586 {
587 112 ▶ my ( $self ) = @_;
Subroutine get_default_expires_in: called CC=1 SCAR=0.0
Pod documented
588  
589 112 return $self->{_Default_Expires_In};
590 }
591  
592  
593 sub _set_default_expires_in
594 {
595 50 ▶ my ( $self, $default_expires_in ) = @_;
Subroutine _set_default_expires_in: called CC=1 SCAR=0.0
596  
597 50 $self->{_Default_Expires_In} = $default_expires_in;
598 }
599  
600  
601 sub get_auto_purge_interval
602 {
603 146 ▶ my ( $self ) = @_;
Subroutine get_auto_purge_interval: called CC=1 SCAR=0.0
Pod undocumented
604  
605 146 return $self->{_Auto_Purge_Interval};
606 }
607  
608  
609 sub set_auto_purge_interval
610 {
611 8 ▶ my ( $self, $auto_purge_interval ) = @_;
Subroutine set_auto_purge_interval: called CC=1 SCAR=0.0
Pod undocumented
612  
613 8 $self->{_Auto_Purge_Interval} = $auto_purge_interval;
614  
615 8 $self->_reset_auto_purge_interval( );
616 }
617  
618  
619 sub get_auto_purge_on_set
620 {
621 112 ▶ my ( $self ) = @_;
Subroutine get_auto_purge_on_set: called CC=1 SCAR=0.0
Pod undocumented
622  
623 112 return $self->{_Auto_Purge_On_Set};
624 }
625  
626  
627 sub set_auto_purge_on_set
628 {
629 54 ▶ my ( $self, $auto_purge_on_set ) = @_;
Subroutine set_auto_purge_on_set: called CC=1 SCAR=0.0
Pod undocumented
630  
631 54 $self->{_Auto_Purge_On_Set} = $auto_purge_on_set;
632 }
633  
634  
635 sub get_auto_purge_on_get
636 {
637 88 ▶ my ( $self ) = @_;
Subroutine get_auto_purge_on_get: called CC=1 SCAR=0.0
Pod undocumented
638  
639 88 return $self->{_Auto_Purge_On_Get};
640 }
641  
642  
643 sub set_auto_purge_on_get
644 {
645 50 ▶ my ( $self, $auto_purge_on_get ) = @_;
Subroutine set_auto_purge_on_get: called CC=1 SCAR=0.0
Pod undocumented
646  
647 50 $self->{_Auto_Purge_On_Get} = $auto_purge_on_get;
648 }
649  
650  
651 sub _get_backend
652 {
653 846 ▶ my ( $self ) = @_;
Subroutine _get_backend: called CC=1 SCAR=0.0
654  
655 846 return $self->{ _Backend };
656 }
657  
658  
659 sub _set_backend
660 {
661 50 ▶ my ( $self, $p_backend ) = @_;
Subroutine _set_backend: called CC=1 SCAR=0.0
662  
663 50 $self->{ _Backend } = $p_backend;
664 }
665  
666  
667  
668 4 1;
669  
670  
671 __END__
« CacheTester.pm ↑ Summary SizeAwareCacheTester.pm »