Apache-iNcom

 view release on metacpan or  search on metacpan

NEWS  view on Meta::CPAN

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Changes in Apache::iNcom 0.08 Mar 30 2000
 
- New configuration directive : INCOM_SESSION_SERIALIZE_ACCESS
 
    If you set this directive to 1, only one request by session will
    be processed simultaneously. This is necessary if you are using
    frames and your database doesn't support full serializable
    transaction isolation level, so that one request overwrites changes
    made in the other request.
 
    You will need to add a field locked_by of type INT to your
    sessions table.
 
 
- Periodic garbage collection of of expired sessions.
 
- New input filters :
 
        integer, pos_integer, neg_integer,
        decimal, pos_decimal, neg_decimal,
        phone, dollars, quotemeta, uc, lc, ucfirst,

lib/Apache/Session/DBIBase64Store.pm  view on Meta::CPAN

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
=head1 SCHEMA
 
This modules expect a table created with the following schema :
 
    CREATE TABLE sessions (
        id          CHAR(32) PRIMARY KEY,
        length      INT,
        a_session   TEXT,
        created     TIMESTAMP DEFAULT 'now()',
        last_update TIMESTAMP DEFAULT 'now()'
        locked_by   INT
    );
 
 
The previous SQL statement is valid for PostgreSQL. Adapt for your
specific DBMS.
 
NOTE: The id length can be fine tuned for specific application. By
default, L<Apache::Session|Apache::Session> uses 16 char length ID,
but I usually use 128 bits ID (32 chars).

lib/Apache/iNcom/SessionLocker.pm  view on Meta::CPAN

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
}
 
sub release_lock {
    my ( $self, $session ) = @_;
 
    return unless $session->{args}{Serialize};
 
    my $dbh = $session->{args}{dbh}
      or die "No opened database connection\n";
 
    my $sth =$dbh->prepare( qq{ UPDATE sessions SET locked_by = NULL
                                 WHERE id = ? AND locked_by = ? } );
 
    $sth->execute( $session->{data}{_session_id}, $$ );
    $sth->finish;
    $dbh->commit;
}
 
sub acquire_lock {
    my ( $self, $session ) = @_;
 
    return unless $session->{args}{Serialize};
 
    # No need for lock in new session
    return if $session->is_new;
 
    # Only need one database lock
    return if $$self++;
 
    my $dbh = $session->{args}{dbh}
      or die "No opened database connection\n";
 
    my $sth =$dbh->prepare( qq{ UPDATE sessions SET locked_by = ?
                                 WHERE id = ? AND locked_by IS NULL } );
 
    my $sel_sth =$dbh->prepare( qq{ SELECT id FROM sessions
                                    WHERE id = ? AND locked_by = ? } );
 
    my $try     = 0;
    my $success = 0;
    while ( ! $success ) {
        if ( $sth->execute( $$, $session->{data}{_session_id} ) ) {
            $dbh->commit;
            # Make sure that we have the lock
            $sel_sth->execute( $session->{data}{_session_id}, $$ );
 
            my $results = $sel_sth->fetchrow_arrayref;

lib/Apache/iNcom/SessionLocker.pm  view on Meta::CPAN

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
=head1 SCHEMA
 
This modules expect a table created with the following schema :
 
    CREATE TABLE sessions (
        id          CHAR(32) PRIMARY KEY,
        length      INT,
        a_session   TEXT,
        created     TIMESTAMP DEFAULT 'now()',
        last_update TIMESTAMP DEFAULT 'now()',
        locked_by   INT
    );
 
The previous SQL statement is valid for PostgreSQL. Adapt for your
specific DBMS.
 
=head1 AUTHOR
 
Copyright (c) 1999 Francis J. Lacoste and iNsu Innovations Inc.
All rights reserved.



( run in 0.324 second using v1.01-cache-2.11-cpan-cba739cd03b )