"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/b/dbi.b" (15 Sep 2009, 893 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) Limbo source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use Apache::Session::DBI;
    2 use DBI;
    3 use Benchmark;
    4 
    5 use vars qw($dbh $id);
    6 
    7 $dbh = DBI->connect('dbi:mysql:sessions', 'test', '', {RaiseError => 1});
    8 
    9 
   10 sub new_session {
   11     my $s;
   12     tie %$s, 'Apache::Session::DBI', undef, {Handle => $dbh};
   13 }
   14 
   15 sub get_id {
   16     my $s;
   17     tie %$s, 'Apache::Session::DBI', undef, {Handle => $dbh};
   18     
   19     $id = $s->{_session_id};
   20 }
   21 
   22 sub reopen {
   23     my $s;
   24     tie %$s, 'Apache::Session::DBI', $id, {Handle => $dbh};
   25 }
   26 
   27 sub openread {
   28     my $s;
   29     tie %$s, 'Apache::Session::DBI', $id, {Handle => $dbh};
   30     
   31     my $sid = $s->{_session_id};
   32 }
   33 
   34 sub openwrite {
   35     my $s;
   36     tie %$s, 'Apache::Session::DBI', $id, {Handle => $dbh};
   37 
   38     $s->{foo} = 'bar';
   39 }
   40 
   41 &get_id;
   42 
   43 timethese(10000, {
   44     'New' => \&new_session,
   45     'Reopen' => \&reopen,
   46     'Read Old' => \&openread,
   47     'Write Old' => \&openwrite,
   48 });