| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dancer2::Session::CHI; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Dancer 2 session storage with CHI backend |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
11656
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
62
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
51
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use Moo; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
15
|
|
|
8
|
2
|
|
|
2
|
|
2008
|
use CHI; |
|
|
2
|
|
|
|
|
74317
|
|
|
|
2
|
|
|
|
|
78
|
|
|
9
|
2
|
|
|
2
|
|
21
|
use Type::Tiny; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
61
|
|
|
10
|
2
|
|
|
2
|
|
13
|
use Types::Standard qw/ Str ArrayRef InstanceOf HashRef/; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
42
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# Public attributes |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
has 'driver' => ( |
|
16
|
|
|
|
|
|
|
is => 'ro', |
|
17
|
|
|
|
|
|
|
isa => Str, |
|
18
|
|
|
|
|
|
|
required => 1, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'driver_args' => ( |
|
22
|
|
|
|
|
|
|
is => 'ro', |
|
23
|
|
|
|
|
|
|
isa => HashRef, |
|
24
|
|
|
|
|
|
|
required => 0, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# |
|
28
|
|
|
|
|
|
|
# Private attributes |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
has _chi => ( |
|
31
|
|
|
|
|
|
|
is => 'lazy', |
|
32
|
|
|
|
|
|
|
isa => InstanceOf ['CHI::Driver'], |
|
33
|
|
|
|
|
|
|
handles => { |
|
34
|
|
|
|
|
|
|
_destroy => 'remove', |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Session methods |
|
39
|
|
|
|
|
|
|
sub _retrieve { |
|
40
|
7
|
|
|
7
|
|
85770
|
my ($self) = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
7
|
|
|
|
|
130
|
return $self->_chi->get( @_ ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _flush { |
|
46
|
7
|
|
|
7
|
|
270305
|
my ($self) = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
7
|
|
|
|
|
149
|
return $self->_chi->set( @_ ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build__chi { |
|
52
|
1
|
|
|
1
|
|
15
|
my ($self) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return CHI->new( |
|
55
|
|
|
|
|
|
|
driver => $self->driver, |
|
56
|
1
|
|
|
|
|
6
|
%{ $self->driver_args }, |
|
|
1
|
|
|
|
|
14
|
|
|
57
|
|
|
|
|
|
|
); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
61
|
|
|
|
|
|
|
my $orig = shift; |
|
62
|
|
|
|
|
|
|
my $class = shift; |
|
63
|
|
|
|
|
|
|
my @args = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my %chi_args = @args; |
|
66
|
|
|
|
|
|
|
delete $chi_args{ $_ } foreach qw( postponed_hooks log_cb session_dir driver ); |
|
67
|
|
|
|
|
|
|
push @args, 'driver_args', \%chi_args; |
|
68
|
|
|
|
|
|
|
return $class->$orig( @args ); |
|
69
|
|
|
|
|
|
|
}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
# Role composition |
|
73
|
|
|
|
|
|
|
# |
|
74
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::SessionFactory'; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
|
0
|
sub _sessions { my $self = shift; return $self->_chi->get_keys; } |
|
|
0
|
|
|
|
|
0
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _change_id { |
|
79
|
1
|
|
|
1
|
|
645
|
my ( $self, $old_id, $new_id ) = @_; |
|
80
|
1
|
|
|
|
|
5
|
$self->_flush( $new_id, $self->_retrieve( $old_id ) ); |
|
81
|
1
|
|
|
|
|
382
|
$self->_destroy( $old_id ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |