line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Session::Storage::Redis; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1498
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
44
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
1
|
|
|
1
|
|
52
|
eval "use Cache::Redis;"; |
|
1
|
|
|
1
|
|
158
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
50
|
|
|
|
4
|
if ($@) { |
11
|
1
|
|
|
|
|
216
|
warn "You must install the Cache::Redis module from CPAN to use the redis storage engine!" |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
WWW::Session::Storage::Redis - Redis storage for WWW::Session |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Redis backend for WWW::Session |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Version 0.01 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module is used for storring serialized WWW::Session objects in redis |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Usage : |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use WWW::Session::Storage::Redis; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $storage = WWW::Session::Storage::Redis->new({ server => ["127.0.0.1:6379"] }); |
42
|
|
|
|
|
|
|
... |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$storage->save($session_id,$expires,$serialized_data); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $serialized_data = $storage->retrive($session_id); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 new |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Creates a new WWW::Session::Storage::Redis object |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This method accepts only one argument, a hashref that contains all the options |
55
|
|
|
|
|
|
|
that will be passed to the Cache::Redis module. The mendatory key in the hash |
56
|
|
|
|
|
|
|
is "server" which must be a scalar containing the C server we want to |
57
|
|
|
|
|
|
|
use. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
See Cache::Redis module for more details on available options |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Example : |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $storage = WWW::Session::Storage::Redis->new({ server => "127.0.0.1:6379" }); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
sub new { |
67
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
68
|
0
|
|
|
|
|
|
my $params = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $self = { options => $params, |
71
|
|
|
|
|
|
|
redis => Cache::Redis->new(%$params), |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
bless $self, $class; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 save |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Stores the given information into the file |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
sub save { |
85
|
0
|
|
|
0
|
1
|
|
my ($self,$sid,$expires,$string) = @_; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
return $self->{redis}->set($sid,$string,$expires == -1 ? undef : $expires ); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 retrieve |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Retrieves the informations for a session, verifies that it's not expired and returns |
93
|
|
|
|
|
|
|
the string containing the serialized data |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
sub retrieve { |
97
|
0
|
|
|
0
|
1
|
|
my ($self,$sid) = @_; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return $self->{redis}->get($sid); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 delete |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Completely removes the session data for the given session id |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
sub delete { |
108
|
0
|
|
|
0
|
1
|
|
my ($self,$sid) = @_; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$self->{redis}->remove($sid); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Jeffrey Goff, C<< >> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 BUGS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
120
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
121
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SUPPORT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
perldoc WWW::Session::Storage::Redis |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You can also look for information at: |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=over 4 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * CPAN Ratings |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * Search CPAN |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copyright 2015 Evozon |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
164
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
165
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
1; # End of WWW::Session::Storage::Redis |