line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Lemonldap::NG::Common::Apache::Session::Store; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = 1.4.0; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
8
|
0
|
|
|
|
|
|
return bless {}, $class; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub insert { |
12
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
13
|
0
|
|
|
|
|
|
my $session = shift; |
14
|
0
|
|
|
|
|
|
$self->{args} = $session->{args}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Store session in cache |
17
|
0
|
|
|
|
|
|
my $id = $session->{data}->{_session_id}; |
18
|
0
|
|
|
|
|
|
$self->cache->set( $id, $session->{serialized} ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Store in session backend |
21
|
0
|
|
|
|
|
|
return $self->module->insert($session); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub update { |
25
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
26
|
0
|
|
|
|
|
|
my $session = shift; |
27
|
0
|
|
|
|
|
|
$self->{args} = $session->{args}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Update session in cache |
30
|
0
|
|
|
|
|
|
my $id = $session->{data}->{_session_id}; |
31
|
0
|
0
|
|
|
|
|
if ( $self->cache->get($id) ) { |
32
|
0
|
|
|
|
|
|
$self->cache->remove($id); |
33
|
0
|
|
|
|
|
|
$self->cache->set( $id, $session->{serialized} ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Update session in backend |
37
|
0
|
|
|
|
|
|
return $self->module->update($session); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub materialize { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my $session = shift; |
43
|
0
|
|
|
|
|
|
$self->{args} = $session->{args}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Get session from cache |
46
|
0
|
|
|
|
|
|
my $id = $session->{data}->{_session_id}; |
47
|
0
|
0
|
|
|
|
|
if ( $self->cache->get($id) ) { |
48
|
0
|
|
|
|
|
|
$session->{serialized} = $self->cache->get($id); |
49
|
0
|
|
|
|
|
|
return; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Get session from backend |
53
|
0
|
|
|
|
|
|
$self->module->materialize($session); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Store session in cache |
56
|
0
|
|
|
|
|
|
$self->cache->set( $id, $session->{serialized} ); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub remove { |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
my $session = shift; |
64
|
0
|
|
|
|
|
|
$self->{args} = $session->{args}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Remove session from cache |
67
|
0
|
|
|
|
|
|
my $id = $session->{data}->{_session_id}; |
68
|
0
|
0
|
|
|
|
|
if ( $self->cache->get($id) ) { |
69
|
0
|
|
|
|
|
|
$self->cache->remove($id); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Remove session from backend |
73
|
0
|
|
|
|
|
|
return $self->module->remove($session); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub close { |
77
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
78
|
0
|
|
|
|
|
|
my $session = shift; |
79
|
0
|
|
|
|
|
|
$self->{args} = $session->{args}; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return $self->module->close; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub module { |
85
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
|
return $self->{args}->{object_store}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub cache { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
return $self->{cache} if $self->{cache}; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $module = $self->{args}->{localStorage}; |
95
|
0
|
|
|
|
|
|
eval "use $module;"; |
96
|
0
|
|
|
|
|
|
$self->{cache} = $module->new( $self->{args}->{localStorageOptions} ); |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $self->{cache}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |