File Coverage

blib/lib/Plack/Middleware/Throttle/Lite/Backend/Simple.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 22 22 100.0


line stmt bran cond sub pod time code
1             package Plack::Middleware::Throttle::Lite::Backend::Simple;
2              
3             # ABSTRACT: Simple (in-memory) backend for Throttle::Lite
4              
5 7     7   29207 use strict;
  7         14  
  7         271  
6 7     7   42 use warnings;
  7         13  
  7         257  
7 7     7   1416 use parent 'Plack::Middleware::Throttle::Lite::Backend::Abstract';
  7         384  
  7         59  
8              
9             our $VERSION = '0.05'; # VERSION
10             our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY
11              
12             my $_storage;
13              
14             sub reqs_done {
15 344     344 1 3597 my ($self) = @_;
16 344 100       1073 exists $_storage->{$self->cache_key} ? $_storage->{$self->cache_key} : 0;
17             }
18              
19             sub increment {
20 62     62 1 348 my ($self) = @_;
21 62         196 $_storage->{$self->cache_key}++;
22             }
23              
24             1; # End of Plack::Middleware::Throttle::Lite::Backend::Simple
25              
26             __END__