line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Session::Driver::aggregator::Drivers; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id$ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
CGI::Session::Driver::aggregator::Drivers - Drivers container for CGI::Session::Driver::aggregator |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
18937
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
57
|
|
12
|
2
|
|
|
2
|
|
10
|
use Carp qw(croak); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
353
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
0
|
381
|
sub new { bless { drivers => [] }, shift } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 add($driver_name, $driver_arguments) |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Adding a driver with extra arguments. driver_arguments will be used to instanctiate the driver. The driver must be an instance of CGI::Session::Driver. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$drivers = CGI::Session::Driver::aggregator::Drivers->new; |
25
|
|
|
|
|
|
|
$drivers->add('file', { Directory => '/tmp' }); |
26
|
|
|
|
|
|
|
$drivers->add('mysql', { Handle => $dbh }); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
NOTE: session data is read from drivers in the added order. In above example, reading from 'file' first, and then from 'mysql' (only when cannot read from 'file'). On the other hand, When writing session data, the order is 'mysql' -> 'file'. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
sub add { |
32
|
4
|
|
|
4
|
1
|
31
|
my ($self, $name, $args) = @_; |
33
|
4
|
|
|
|
|
11
|
$name = lc $name; |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
10
|
my $package = "CGI::Session::Driver::$name"; |
36
|
4
|
50
|
|
|
|
14
|
if (!exists $INC{$package}) { |
37
|
4
|
|
|
|
|
204
|
eval "require $package"; |
38
|
4
|
50
|
|
|
|
4911
|
if ($@) { |
39
|
0
|
|
|
|
|
0
|
croak "Failed to load a driver: $@"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
11
|
push @{ $self->{drivers} }, { package => $package, args => $args }; |
|
4
|
|
|
|
|
33
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
3
|
0
|
7
|
sub drivers { @{ shift->{drivers} } } |
|
3
|
|
|
|
|
16
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |