Stored/Storage/Redis.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 30 CC 1 SCAR 6.9
CC
1
Cov
0%
store
2.0
retrieve
2.0
BEGIN
2.0
CRAP 2.0
1 package Time::Progress::Stored::Storage::Redis;
2 $Time::Progress::Stored::Storage::Redis::VERSION = '1.002';
3 use Moo;
4 use true;
5 extends "Time::Progress::Stored::Storage";
6  
7 =head1 NAME
8  
9 Time::Progress::Stored::Storage::Redis - Store the reports in Redis
10  
11 =cut
12  
13 use JSON::Tiny qw/ encode_json decode_json /;
14  
15  
16  
17 =head1 PROPERTIES
18  
19 =cut
20  
21 has redis => (
22 is => "ro",
23 isa => sub { shift->isa("Redis") },
24 required => 1,
25 );
26  
27  
28  
29 =head1 METHODS
30  
31 =head2 store($id, $content) : Bool
32  
33 Store the current report $content (a data structure) under the $id
34 key.
35  
36 =cut
37  
38 sub store {
39 my $self = shift;
40 my ($id, $content) = @_;
41 $self->redis->set( $id , encode_json($content) );
42 }
43  
44 =head2 retrieve($id) : $content | undef
45  
46 Retrieve the current report $content under the $id key, or undef if
47 none was found.
48  
49 =cut
50  
51 sub retrieve {
52 my $self = shift;
53 my ($id) = @_;
54 my $report_json = $self->redis->get($id) // return undef;
55 return decode_json( $report_json );
56 }