Session/MySQL/NoLock.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
populate
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #############################################################################
2 #
3 # Apache::Session::MySQL::NoLock
4 # Apache persistent user sessions in a MySQL database without locking
5 # Copyright(c) 2010 Tomas (t0m) Doran (bobtfish@bobtfish.net)
6 # Distribute under the Perl License
7 #
8 ############################################################################
9
10 package Apache::Session::MySQL::NoLock;
11
12 use strict;
13 use vars qw(@ISA $VERSION);
14
15 $VERSION = '0.01';
16 @ISA = qw(Apache::Session);
17
18 use Apache::Session;
19 use Apache::Session::Lock::Null;
20 use Apache::Session::Store::MySQL;
21 use Apache::Session::Generate::MD5;
22 use Apache::Session::Serialize::Storable;
23
24 sub populate {
25 my $self = shift;
26
27 $self->{object_store} = Apache::Session::Store::MySQL->new($self);
28 $self->{lock_manager} = Apache::Session::Lock::Null->new($self);
29 $self->{generate} = \&Apache::Session::Generate::MD5::generate;
30 $self->{validate} = \&Apache::Session::Generate::MD5::validate;
31 $self->{serialize} = \&Apache::Session::Serialize::Storable::serialize;
32 $self->{unserialize} = \&Apache::Session::Serialize::Storable::unserialize;
33
34 return $self;
35 }
36
37 1;
38
39 =pod
40
41 =head1 NAME
42
43 Apache::Session::MySQL::NoLock - An implementation of Apache::Session::MySQL without locking
44
45 =head1 SYNOPSIS
46
47 use Apache::Session::MySQL::NoLock;
48
49 #if you want Apache::Session to open new DB handles:
50
51 tie %hash, 'Apache::Session::MySQL::NoLock', $id, {
52 DataSource => 'dbi:mysql:sessions',
53 UserName => $db_user,
54 Password => $db_pass,
55 };
56
57 #or, if your handles are already opened:
58
59 tie %hash, 'Apache::Session::MySQL::NoLock', $id, {
60 Handle => $dbh,
61 };
62
63 To configure the non-locking session store in RT (what I use this module for),
64 put the following into your C<RT_SiteConfig.pm> module:
65
66 Set($WebSessionClass , 'Apache::Session::MySQL::NoLock');
67
68 =head1 DESCRIPTION
69
70 This module is an implementation of Apache::Session. It uses the MySQL backing
71 store and the Null locking scheme. See the example, and the documentation for
72 Apache::Session::Store::MySQL for more details.
73
74 =head1 WARNING
75
76 This module explicitly B<DOES NOT DO ANY LOCKING>. This can cause your session
77 data to be overwritten or stale data to be read by subsequent requests.
78
79 This B<CAN CAUSE LARGE PROBLEMS IN YOUR APPLICATION>.
80
81 =head1 AUTHOR
82
83 This module was written by Tomas Doran <bobtfish@bobtfish.net>.
84
85 =head1 SEE ALSO
86
87 L<Apache::Session::MySQL>, L<Apache::Session::Flex>,
88 L<Apache::Session>
89
90 =cut
91
92