line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Driver::aggregator; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id$ |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
733811
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
62
|
|
6
|
2
|
|
|
2
|
|
11
|
use Carp qw(croak); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
80
|
|
7
|
2
|
|
|
2
|
|
11
|
use CGI::Session::Driver; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
734
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@CGI::Session::Driver::aggregator::ISA = ( "CGI::Session::Driver" ); |
10
|
|
|
|
|
|
|
$CGI::Session::Driver::aggregator::VERSION = "0.04"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub drivers { |
13
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
14
|
4
|
|
|
|
|
8
|
return @{ $self->{drivers} }; |
|
4
|
|
|
|
|
11
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
3
|
|
|
3
|
1
|
1060702
|
my $self = shift; |
19
|
3
|
50
|
|
|
|
26
|
unless (defined $self->{Drivers}) { |
20
|
0
|
|
|
|
|
0
|
return $self->set_error("init(): 'Drivers' attribute is required."); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
8
|
my @drivers; |
24
|
3
|
|
50
|
|
|
26
|
$self->{drivers} ||= []; |
25
|
3
|
|
|
|
|
18
|
for my $d ( $self->{Drivers}->drivers ) { |
26
|
6
|
|
|
|
|
41
|
my $obj = $d->{package}->new($d->{args}); |
27
|
6
|
|
|
|
|
274
|
push @drivers, $obj; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
7
|
$self->{drivers} = \@drivers; |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
9
|
return 1; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub retrieve { |
36
|
2
|
|
|
2
|
1
|
20
|
my $self = shift; |
37
|
2
|
|
|
|
|
6
|
my ($sid) = @_; |
38
|
2
|
50
|
|
|
|
6
|
croak "retrieve(): usage error" unless $sid; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
7
|
for my $driver ($self->drivers) { |
41
|
3
|
100
|
|
|
|
98
|
if (my $data = $driver->retrieve(@_)) { |
42
|
1
|
|
|
|
|
189
|
return $data; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
35
|
return 0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub store { |
50
|
2
|
|
|
2
|
1
|
7239
|
my $self = shift; |
51
|
2
|
|
|
|
|
6
|
my ($sid, $datastr) = @_; |
52
|
2
|
50
|
33
|
|
|
16
|
croak "store(): usage error" unless $sid && $datastr; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
7
|
for my $driver (reverse $self->drivers) { |
55
|
4
|
|
|
|
|
510
|
$driver->store(@_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
298
|
return 1; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub remove { |
62
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
63
|
0
|
|
|
|
|
0
|
my ($sid) = @_; |
64
|
0
|
0
|
|
|
|
0
|
croak "remove(): usage error" unless $sid; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
for my $driver (reverse $self->drivers) { |
67
|
0
|
|
|
|
|
0
|
$driver->remove(@_); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
return 1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub DESTROY { |
75
|
3
|
|
|
3
|
|
2445
|
my $self = shift; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub traverse { |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my ($coderef) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
0
|
|
|
|
unless ( $coderef && ref( $coderef ) && (ref $coderef eq 'CODE') ) { |
|
|
|
0
|
|
|
|
|
83
|
0
|
|
|
|
|
|
croak "traverse(): usage error"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
for my $driver ($self->drivers) { |
87
|
0
|
|
|
|
|
|
$driver->traverse(@_); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return 1; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=pod |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
CGI::Session::Driver::aggregator - CGI::Session driver to aggregate some CGI::Session drivers. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SYNOPSIS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
use CGI::Session; |
105
|
|
|
|
|
|
|
use CGI::Session::Driver::aggregator::Drivers; |
106
|
|
|
|
|
|
|
use DBI; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$dbh = DBI->connect('DBI:mysql:cgi_session;host=localhost', 'root', ''); |
109
|
|
|
|
|
|
|
$drivers = CGI::Session::Driver::aggregator::Drivers->new; |
110
|
|
|
|
|
|
|
$drivers->add('file', { Directory => '/tmp' }); |
111
|
|
|
|
|
|
|
$drivers->add('mysql', { Handle => $dbh }); |
112
|
|
|
|
|
|
|
$s = CGI::Session->new('driver:aggregator', $sid, { Drivers => $drivers }); |
113
|
|
|
|
|
|
|
$s->param(hey => 'Blur blur blur!'); |
114
|
|
|
|
|
|
|
# ----> Store datas into mysql and file!! |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$value = $s->param('hey'); |
117
|
|
|
|
|
|
|
# ----> Read datas from file (When cannot find, then from mysql) |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
B stores session data into anything to be set up. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 DRIVER ARGUMENTS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The only supported driver argument is 'Drivers'. It's an instance of L. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 REQUIREMENTS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over 4 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=back |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 AUTHOR |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Kazuhiro Oinuma |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Copyright (C) 2005 - 2006 Kazuhiro Oinuma . All rights reserved. This library is free software. You can modify and or distribute it under the same terms as Perl itself. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|