File Coverage

blib/lib/Sentry/Cache.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition 2 3 66.6
subroutine 5 5 100.0
pod 0 4 0.0
total 31 36 86.1


line stmt bran cond sub pod time code
1             package Sentry::Cache;
2 8     8   546245 use Mojo::Base -base, -signatures;
  8         13  
  8         98  
3              
4             has _cache => sub { {} };
5              
6             my $Instance;
7              
8 2     2 0 1050 sub get_instance ($package) {
  2         3  
  2         1  
9 2   66     9 $Instance //= $package->new;
10 2         10 return $Instance;
11             }
12              
13 5     5 0 331245 sub set ($self, $key, $value) {
  5         11  
  5         7  
  5         6  
  5         8  
14 5         13 $self->_cache->{$key} = $value;
15             }
16              
17 8     8 0 701 sub get ($self, $key) {
  8         9  
  8         12  
  8         10  
18 8         15 return $self->_cache->{$key};
19             }
20              
21             # `has` is taken by Mojo::Base, so we have to use a different name
22 5     5 0 35 sub exists ($self, $key) {
  5         12  
  5         7  
  5         5  
23 5         12 return exists $self->_cache->{$key};
24             }
25              
26             1;