File Coverage

blib/lib/WebService/GrowthBook/CacheEntry.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 3 0.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package WebService::GrowthBook::CacheEntry;
2 8     8   255307 use strict;
  8         21  
  8         554  
3 8     8   116 use warnings;
  8         37  
  8         569  
4 8     8   581 no indirect;
  8         1600  
  8         51  
5 8     8   1330 use Object::Pad;
  8         12176  
  8         87  
6              
7             our $VERSION = '0.003'; ## VERSION
8              
9             class WebService::GrowthBook::CacheEntry {
10 3     3 0 25 field $value :param :reader;
  3         19  
11             field $ttl :param;
12             field $expires; # = time() + $ttl;
13             ADJUST {
14             $expires = time() + $ttl;
15             }
16 1     1 0 3 method update($new_value){
  1         4  
  1         2  
  1         2  
17 1         3 $value = $new_value;
18 1         5 $expires = time() + $ttl;
19             }
20 4     4 0 8 method expired(){
  4         12  
  4         9  
21 4         18 return $expires < time();
22             }
23             }
24             1;