File: dbi.b

package info (click to toggle)
libapache-session-perl 1.94-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 448 kB
  • sloc: perl: 1,514; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use Apache::Session::DBI;
use DBI;
use Benchmark;

use vars qw($dbh $id);

$dbh = DBI->connect('dbi:mysql:sessions', 'test', '', {RaiseError => 1});


sub new_session {
    my $s;
    tie %$s, 'Apache::Session::DBI', undef, {Handle => $dbh};
}

sub get_id {
    my $s;
    tie %$s, 'Apache::Session::DBI', undef, {Handle => $dbh};
    
    $id = $s->{_session_id};
}

sub reopen {
    my $s;
    tie %$s, 'Apache::Session::DBI', $id, {Handle => $dbh};
}

sub openread {
    my $s;
    tie %$s, 'Apache::Session::DBI', $id, {Handle => $dbh};
    
    my $sid = $s->{_session_id};
}

sub openwrite {
    my $s;
    tie %$s, 'Apache::Session::DBI', $id, {Handle => $dbh};

    $s->{foo} = 'bar';
}

&get_id;

timethese(10000, {
    'New' => \&new_session,
    'Reopen' => \&reopen,
    'Read Old' => \&openread,
    'Write Old' => \&openwrite,
});