line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Driver::chi; |
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
CGI::Session::Driver::chi |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=cut |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$s = CGI::Session->new( |
11
|
|
|
|
|
|
|
"driver:chi", |
12
|
|
|
|
|
|
|
$sid, { |
13
|
|
|
|
|
|
|
driver => 'File', |
14
|
|
|
|
|
|
|
root_dir => '/path/to/root' |
15
|
|
|
|
|
|
|
}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$s = CGI::Session->new( |
18
|
|
|
|
|
|
|
"driver:chi", |
19
|
|
|
|
|
|
|
$sid, { |
20
|
|
|
|
|
|
|
chi_class => 'My::CHI', |
21
|
|
|
|
|
|
|
namespace => 'cgi', |
22
|
|
|
|
|
|
|
}); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This driver allows L to use L as a session store |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 DRIVER ARGUMENTS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
It accept a hash ref with the same arguements to would pass to L |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
An additional arguement chi_class |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
21797
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
41
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
29
|
|
44
|
1
|
|
|
1
|
|
425
|
use CHI; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use base qw( CGI::Session::Driver CGI::Session::ErrorHandler ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our $VERSION = '1.0.3'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub init { |
50
|
|
|
|
|
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
my %args = %$self; |
52
|
|
|
|
|
|
|
my $chi_class = delete $args{chi_class} || "CHI"; |
53
|
|
|
|
|
|
|
my $chi = $chi_class->new(%args); |
54
|
|
|
|
|
|
|
$self->{CHI} = $chi; |
55
|
|
|
|
|
|
|
return 1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub store { |
59
|
|
|
|
|
|
|
my ($self, $sid, $datastr) = @_; |
60
|
|
|
|
|
|
|
$self->{CHI}->set($sid, $datastr); |
61
|
|
|
|
|
|
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub retrieve { |
65
|
|
|
|
|
|
|
my ($self, $sid) = @_; |
66
|
|
|
|
|
|
|
my $value = $self->{CHI}->get($sid); |
67
|
|
|
|
|
|
|
return 0 unless defined $value; |
68
|
|
|
|
|
|
|
return $value; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub remove { |
72
|
|
|
|
|
|
|
my ($self, $sid) = @_; |
73
|
|
|
|
|
|
|
$self->{CHI}->remove($sid); |
74
|
|
|
|
|
|
|
return 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub traverse { |
78
|
|
|
|
|
|
|
my ($self, $coderef) = @_; |
79
|
|
|
|
|
|
|
foreach my $key ($self->{CHI}->get_keys) { |
80
|
|
|
|
|
|
|
$coderef->( $key ) |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
return 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
James Rouzier. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright (C) 2013 James Rouzier |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 LICENSE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
96
|
|
|
|
|
|
|
modify it under the terms of the GNU General Public License |
97
|
|
|
|
|
|
|
as published by the Free Software Foundation; either version 2 |
98
|
|
|
|
|
|
|
of the License, or (at your option) any later version. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
101
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
102
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
103
|
|
|
|
|
|
|
GNU General Public License for more details. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
106
|
|
|
|
|
|
|
along with this program; if not, write to the Free Software |
107
|
|
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
108
|
|
|
|
|
|
|
USA. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |