Session/Backend/Memory.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 86.6% 39 / 45 CC 3 SCAR 3.5
CC
3
Cov
91%
get
2.0
set
2.0
__ANON__
2.0
CRAP 1.4
« Session/Role.pm ↑ Summary Session/Role/Memory.pm »
1 #
2 # This file is part of Jedi-Plugin-Session
3 #
4 # This software is copyright (c) 2013 by celogeek <me@celogeek.com>.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package Jedi::Plugin::Session::Backend::Memory;
10  
11 # ABSTRACT: Backend storage for Memory
12  
13 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 our $VERSION = '0.05'; # VERSION
16 3 ▶use Time::Duration::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Cache::LRU::WithExpires;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 3 has '_cache' => ( is => 'lazy' );
21  
22 2 ▶sub _build__cache {
Subroutine _build__cache: called CC=1 SCAR=0.0
23 2 return Cache::LRU::WithExpires->new;
24 }
25  
26 has 'expires_in' => (
27 is => 'ro',
28 0 ▶ default => sub { 3 * 3600 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 2 ▶ coerce => sub { parse_duration( $_[0] ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
30 3 );
31  
32 ## no critic (NamingConventions::ProhibitAmbiguousNames)
33 9 ▶sub get {
Subroutine get: called CC=2 SCAR=7.1
Pod undocumented
34 9 my ( $self, $uuid ) = @_;
35 9 ▶ return if !defined $uuid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uuid 0 9 9
36  
37 9 return $self->_cache->get($uuid);
38 }
39  
40 4 ▶sub set {
Subroutine set: called CC=2 SCAR=7.0
Pod undocumented
41 4 my ( $self, $uuid, $value ) = @_;
42 4 ▶ return if !defined $uuid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uuid 0 4 4
43 4 $self->_cache->set( $uuid, $value, $self->expires_in );
44 4 return 1;
45 }
46  
47 3 1;
48  
49 __END__
« Session/Role.pm ↑ Summary Session/Role/Memory.pm »