GrowthBook/InMemoryFeatureCache.pm

filter: Statementstmt 100% 51 / 51 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 94.4% 68 / 72 CC 4 SCAR 4.5
CC
4
Cov
100%
get
3.0
set
2.0
BEGIN
1.0
CRAP 1.6
« GrowthBook/FeatureResult.pm ↑ Summary GrowthBook/AbstractFeatureCache.pm »
1 package WebService::GrowthBook::InMemoryFeatureCache;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶no indirect;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use feature qw(state);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶use WebService::GrowthBook::CacheEntry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 our $VERSION = '0.003'; ## VERSION
10  
11 7 ▶class WebService::GrowthBook::InMemoryFeatureCache :isa(WebService::GrowthBook::AbstractFeatureCache) {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 field %cache;
13  
14 12 ▶ method get($key){
Subroutine get: called CC=3 SCAR=11.0
Pod undocumented
15 12 my $entry = $cache{$key};
16 12 ▶ return undef unless $entry;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry 8 4 12
17 4 ▶ return $entry->value if !$entry->expired;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->expired 3 1 4
18 1 return undef;
19 7 }
20  
21 4 ▶ method set($key, $value, $ttl){
Subroutine set: called CC=2 SCAR=6.9
Pod undocumented
22 4 ▶ if(exists $cache{$key}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $cache{$key}) 1 3 4
23 1 $cache{$key}->update($value);
24 1 return;
25 }
26 3 $cache{$key} = WebService::GrowthBook::CacheEntry->new(value => $value, ttl => $ttl);
27 7 }
28  
29 1 ▶ method clear(){
Subroutine clear: called CC=1 SCAR=0.0
Pod undocumented
30 1 %cache = ();
31 7 }
32  
33 104 ▶ sub singleton($class){
Subroutine singleton: called CC=1 SCAR=0.0
Pod undocumented
34 104 state $instance = $class->new();
35 104 return $instance;
36 }
37 7 }
« GrowthBook/FeatureResult.pm ↑ Summary GrowthBook/AbstractFeatureCache.pm »