line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: in-memory session backend for Dancer2 |
2
|
|
|
|
|
|
|
$Dancer2::Session::Simple::VERSION = '0.400000'; |
3
|
|
|
|
|
|
|
use Moo; |
4
|
111
|
|
|
111
|
|
61396
|
use Dancer2::Core::Types; |
|
111
|
|
|
|
|
263
|
|
|
111
|
|
|
|
|
885
|
|
5
|
111
|
|
|
111
|
|
39534
|
use Carp; |
|
111
|
|
|
|
|
251
|
|
|
111
|
|
|
|
|
1064
|
|
6
|
111
|
|
|
111
|
|
920909
|
|
|
111
|
|
|
|
|
283
|
|
|
111
|
|
|
|
|
36510
|
|
7
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::SessionFactory'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# The singleton that contains all the session objects created |
10
|
|
|
|
|
|
|
my $SESSIONS = {}; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my ($self) = @_; |
13
|
|
|
|
|
|
|
return [ keys %{$SESSIONS} ]; |
14
|
0
|
|
|
0
|
|
0
|
} |
15
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
16
|
|
|
|
|
|
|
my ( $class, $id ) = @_; |
17
|
|
|
|
|
|
|
my $s = $SESSIONS->{$id}; |
18
|
|
|
|
|
|
|
|
19
|
29
|
|
|
29
|
|
92
|
croak "Invalid session ID: $id" |
20
|
29
|
|
|
|
|
94
|
if !defined $s; |
21
|
|
|
|
|
|
|
|
22
|
29
|
100
|
|
|
|
313
|
return $s; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
28
|
|
|
|
|
112
|
my ( $class, $old_id, $new_id ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$SESSIONS->{$new_id} = $class->_retrieve($old_id); |
28
|
|
|
|
|
|
|
delete $SESSIONS->{$old_id}; |
29
|
2
|
|
|
2
|
|
7
|
} |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
7
|
my ( $class, $id ) = @_; |
32
|
2
|
|
|
|
|
8
|
delete $SESSIONS->{$id}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my ( $class, $id, $data ) = @_; |
36
|
7
|
|
|
7
|
|
23
|
$SESSIONS->{$id} = $data; |
37
|
7
|
|
|
|
|
323
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
10062
|
|
|
10062
|
|
16497
|
|
42
|
10062
|
|
|
|
|
26817
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Dancer2::Session::Simple - in-memory session backend for Dancer2 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 0.400000 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This module implements a very simple session backend, holding all session data |
57
|
|
|
|
|
|
|
in memory. This means that sessions are volatile, and no longer exist when the |
58
|
|
|
|
|
|
|
process exits. This module is likely to be most useful for testing purposes. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DISCLAIMER |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This session factory should not be used in production and is only for |
63
|
|
|
|
|
|
|
single-process application workers. As the sessions objects are stored |
64
|
|
|
|
|
|
|
in-memory, they cannot be shared among multiple workers. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 CONFIGURATION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The setting B<session> should be set to C<Simple> in order to use this session |
69
|
|
|
|
|
|
|
engine in a Dancer2 application. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
See L<Dancer2::Core::Session> for details about session usage in route handlers. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Dancer Core Developers |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Alexis Sukrieh. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
84
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |