« blib/lib/Lemonldap/NG/Common/MessageBroker/NoBroker.pm
↑ Summary
blib/lib/Lemonldap/NG/Common/MessageBroker/Redis.pm »
| 1 | |||||||||||||||||||||||||||||
| 2 | package Lemonldap::NG::Common::Apache::Session::Store; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 7 | our $VERSION = '2.19.0'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 6 | my $class = shift; | |||||||||||||||||||||||||||
| 10 | 6 | return bless {}, $class; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | sub insert { | ||||||||||||||||||||||||||
|
Subroutine
insert: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 15 | 1 | my $session = shift; | |||||||||||||||||||||||||||
| 16 | 1 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Store session in cache | ||||||||||||||||||||||||||||
| 19 | 1 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||
| 20 | 1 | $self->storeInCache( $id, $session->{serialized} ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Store in session backend | ||||||||||||||||||||||||||||
| 23 | 1 | return $self->module->insert($session); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | ▶ | sub update { | ||||||||||||||||||||||||||
|
Subroutine
update: called CC=6 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 2 | my $session = shift; | |||||||||||||||||||||||||||
| 29 | 2 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | #TODO: remove cache on all LL::NG instances if updateCache == 1 | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | ▶ | unless ( defined( $session->{args}->{updateCache} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == -1
MC/DC0%0/2
defined $session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == -1
defined $session->{"args"}{"updateCache"}
$session->{"args"}{"updateCache"} == -1
Truth table33%1/3
A and B
A= defined $session->{"args"}{"updateCache"}B= $session->{"args"}{"updateCache"} == -1
| |||||||||||||||||||||||||||||
| 34 | and $session->{args}->{updateCache} == -1 ) | ||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | # Update session in cache | ||||||||||||||||||||||||||||
| 38 | 2 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||
| 39 | 2 | ▶ | $self->removeFromCache($id) if ( $self->getFromCache($id) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 2 | $self->storeInCache( $id, $session->{serialized} ); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | unless ( defined( $session->{args}->{updateCache} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == 2
MC/DC0%0/2
defined $session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == 2
defined $session->{"args"}{"updateCache"}
$session->{"args"}{"updateCache"} == 2
Truth table33%1/3
A and B
A= defined $session->{"args"}{"updateCache"}B= $session->{"args"}{"updateCache"} == 2
| |||||||||||||||||||||||||||||
| 44 | and $session->{args}->{updateCache} == 2 ) | ||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # Update session in backend | ||||||||||||||||||||||||||||
| 48 | 2 | return $self->module->update($session); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 5 | ▶ | sub materialize { | ||||||||||||||||||||||||||
|
Subroutine
materialize: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 54 | 5 | my $session = shift; | |||||||||||||||||||||||||||
| 55 | 5 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # Get session from cache | ||||||||||||||||||||||||||||
| 58 | 5 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||
| 59 | 5 | ▶ | if ( !$self->{args}->{noCache} and $self->getFromCache($id) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->{"args"}{"noCache"} and $self->getFromCache($id)
MC/DC50%1/2
not $self->{"args"}{"noCache"} and $self->getFromCache($id)
not $self->{"args"}{"noCache"}
$self->getFromCache($id)
Truth table66%2/3
not(A) and B
A= not $self->{"args"}{"noCache"}B= $self->getFromCache($id)
| |||||||||||||||||||||||||||||
| 60 | 2 | $session->{serialized} = $self->getFromCache($id); | |||||||||||||||||||||||||||
| 61 | 2 | eval { JSON::from_json( $session->{serialized} ); }; | |||||||||||||||||||||||||||
| 62 | 2 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 1 | print STDERR "Local data corrupted, ignore cached session\n"; | |||||||||||||||||||||||||||
| 64 | 1 | $session->{serialized} = undef; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | else { | ||||||||||||||||||||||||||||
| 67 | 1 | return; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # Get session from backend | ||||||||||||||||||||||||||||
| 72 | 4 | $self->module->materialize($session); | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Store session in cache | ||||||||||||||||||||||||||||
| 75 | 3 | $self->storeInCache( $id, $session->{serialized} ); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 3 | return; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 82 | 0 | my $session = shift; | |||||||||||||||||||||||||||
| 83 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | #TODO: remove cache on all LL::NG instances if updateCache == 1 | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | unless ($session->{args}->{updateCache} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == -1
MC/DC0%0/2
$session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == -1
$session->{"args"}{"updateCache"}
$session->{"args"}{"updateCache"} == -1
Truth table0%0/3
A and B
A= $session->{"args"}{"updateCache"}B= $session->{"args"}{"updateCache"} == -1
| |||||||||||||||||||||||||||||
| 88 | and $session->{args}->{updateCache} == -1 ) | ||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # Remove session from cache | ||||||||||||||||||||||||||||
| 92 | 0 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | $self->removeFromCache($id) if ( $self->getFromCache($id) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | unless ($session->{args}->{updateCache} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == 2
MC/DC0%0/2
$session->{"args"}{"updateCache"} and $session->{"args"}{"updateCache"} == 2
$session->{"args"}{"updateCache"}
$session->{"args"}{"updateCache"} == 2
Truth table0%0/3
A and B
A= $session->{"args"}{"updateCache"}B= $session->{"args"}{"updateCache"} == 2
| |||||||||||||||||||||||||||||
| 97 | and $session->{args}->{updateCache} == 2 ) | ||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | # Remove session from backend | ||||||||||||||||||||||||||||
| 101 | 0 | return $self->module->remove($session); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 107 | 0 | my $session = shift; | |||||||||||||||||||||||||||
| 108 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | return $self->module->close; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 7 | ▶ | sub module { | ||||||||||||||||||||||||||
|
Subroutine
module: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 114 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 115 | 7 | return $self->{args}->{object_store}; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 17 | ▶ | sub cache { | ||||||||||||||||||||||||||
|
Subroutine
cache: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 119 | 17 | my $self = shift; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 17 | ▶ | return $self->{cache} if $self->{cache}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 6 | my $module = $self->{args}->{localStorage}; | |||||||||||||||||||||||||||
| 124 | 6 | ▶ | eval "use $module;"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 125 | 6 | $self->{cache} = $module->new( $self->{args}->{localStorageOptions} ); | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 6 | return $self->{cache}; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 6 | ▶ | sub storeInCache { _cache_call( 'set', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
storeInCache: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 9 | ▶ | sub getFromCache { _cache_call( 'get', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
getFromCache: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 2 | ▶ | sub removeFromCache { _cache_call( 'remove', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
removeFromCache: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 17 | ▶ | sub _cache_call { | ||||||||||||||||||||||||||
|
Subroutine
_cache_call: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 137 | 17 | my ( $sub, $self, @args ) = @_; | |||||||||||||||||||||||||||
| 138 | 17 | my $res = eval { $self->cache->$sub(@args); }; | |||||||||||||||||||||||||||
| 139 | 17 | ▶ | print STDERR "Unable to use cache: $@\n" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 17 | return $res; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 7 | 1; | |||||||||||||||||||||||||||