"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/lib/Apache/Session/MySQL/NoLock.pm" (24 Dec 2012, 2576 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "NoLock.pm" see the Fossies "Dox" file reference documentation.

    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} = new Apache::Session::Store::MySQL $self;
   28     $self->{lock_manager} = new Apache::Session::Lock::Null $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