my $response_json = $storage->retrieve($progress_id)
or return $self->render(status => 404, json => {});
return $self->render(json => { progress => $response_json });
}
=h
progress report. The request contains the progress id, and
it's simply fetched and returned as a JSON payload.
See above for the contents of the payload.
=head3 Client making a request to a long r
rts in serialized JSON, to emulate storing them in an
external server, which is better than just keeping the hashref around
would be.
=cut
use JSON::Tiny qw/ encode_json decode_json /;
=head1 PRO
tore {
my $self = shift;
my ($id, $content) = @_;
$self->id__report->{ $id } = encode_json( $content );
}
=head2 retrieve($id) : $content | undef
Retrieve the current report $content und
or undef if
none was found.
=cut
sub retrieve {
my $self = shift;
my ($id) = @_;
my $report_json = $self->id__report->{ $id } // return undef;
return decode_json( $report_json );
}
Time::Progress::Stored::Storage::Redis - Store the reports in Redis
=cut
use JSON::Tiny qw/ encode_json decode_json /;
=head1 PROPERTIES
=cut
has redis => (
is => "ro",
isa
ub store {
my $self = shift;
my ($id, $content) = @_;
$self->redis->set( $id , encode_json($content) );
}
=head2 retrieve($id) : $content | undef
Retrieve the current report $content und
key, or undef if
none was found.
=cut
sub retrieve {
my $self = shift;
my ($id) = @_;
my $report_json = $self->redis->get($id) // return undef;
return decode_json( $report_json );
}