| 1 | package MojoX::Authentication::Model::SAML2::Hash; | ||||||||||
| 2 | 13 | { our $VERSION = '0.099001' } | |||||||||
| 3 | |||||||||||
| 4 | 13 | ▶ | use v5.24; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 13 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 13 | ▶ | use experimental qw< signatures >; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 13 | ▶ | use Storable qw< dclone >; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 13 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 17 | ▶ | has _store => (is => 'ro', default => sub { return {} }); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 54 | ▶ | sub get ($self, $key) { | ||||||||
|
Subroutine
get: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||
| 13 | 54 | ▶ | defined(my $rec = $self->_store->{$key}) or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 39 | ▶ | return dclone($rec->{data}) if $rec->{expire} > time(); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 0 | $self->wipe($key); | |||||||||
| 16 | 0 | return; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 37 | ▶ | sub set ($self, $data, $key, $expire) { | ||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 37 | my $store = $self->_store; | |||||||||
| 21 | |||||||||||
| 22 | # cleanup everything that already expired | ||||||||||
| 23 | 37 | my $now = time(); | |||||||||
| 24 | 37 | my @expired = grep { $store->{$_}{expire} <= $now } keys($store->%*); | |||||||||
| 25 | 37 | delete $store->@{@expired}; | |||||||||
| 26 | |||||||||||
| 27 | 37 | $store->{$key} = { | |||||||||
| 28 | expire => $expire, | ||||||||||
| 29 | data => $data, | ||||||||||
| 30 | }; | ||||||||||
| 31 | 37 | return $self; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 22 | ▶ | sub wipe ($self, $key) { | ||||||||
|
Subroutine
wipe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 35 | 22 | delete($self->_store->{$key}); | |||||||||
| 36 | 22 | return $self; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 13 | 1; | |||||||||