Apache-iNcom
view release on metacpan or search on metacpan
34567891011121314151617181920212223Changes 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
183184185186187188189190191192193194195196197198199200201202=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
6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114}
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
154155156157158159160161162163164165166167168169170171172173=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 )