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
10package Apache::Session::MySQL::NoLock;
11
12use strict;
13use vars qw(@ISA $VERSION);
14
15$VERSION = '0.01';
16@ISA = qw(Apache::Session);
17
18use Apache::Session;
19use Apache::Session::Lock::Null;
20use Apache::Session::Store::MySQL;
21use Apache::Session::Generate::MD5;
22use Apache::Session::Serialize::Storable;
23
24sub 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
371;
38
39=pod
40
41=head1 NAME
42
43Apache::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
70This module is an implementation of Apache::Session. It uses the MySQL backing
71store and the Null locking scheme. See the example, and the documentation for
72Apache::Session::Store::MySQL for more details.
73
74=head1 WARNING
75
76This module explicitly B<DOES NOT DO ANY LOCKING>. This can cause your session
77data to be overwritten or stale data to be read by subsequent requests.
78
79This B<CAN CAUSE LARGE PROBLEMS IN YOUR APPLICATION>.
80
81=head1 AUTHOR
82
83This module was written by Tomas Doran <bobtfish@bobtfish.net>.
84
85=head1 SEE ALSO
86
87L<Apache::Session::MySQL>, L<Apache::Session::Flex>,
88L<Apache::Session>
89
90=cut
91
92
93