Apache...:MySQL(3pm)
β¨ NAME β¨
Apache::Session::Lock::MySQL β bestie, it hands you mutual exclusion using MySQL. That's the whole gig. π
Oh and btw, for the record, this page lives in the User Contributed Perl Documentation (that's the 3pm section, iykyk), filed under Apache...:MySQL(3pm) because someone's terminal was too narrow to spell the whole thing out. π
πΈ SYNOPSIS πΈ
use Apache::Session::Lock::MySQL;
my $locker = Apache::Session::Lock::MySQL->new();
$locker->acquire_read_lock($ref);
$locker->acquire_write_lock($ref);
$locker->release_read_lock($ref);
$locker->release_write_lock($ref);
$locker->release_all_locks($ref);
That's the whole dance, fr fr. Make a locker, grab a lock, let go of a lock, repeat until your session is safe. π«Ά
π DESCRIPTION π
Apache::Session::Lock::MySQL fulfills the locking interface of Apache::Session. So like, it's the designated lock girlie for that whole ecosystem. π
The way mutual exclusion happens here is through MySQL's GET_LOCK and RELEASE_LOCK functions. Those are the icons doing all the actual work. β¨
β οΈ Here's the tea though: MySQL does not support the notion of read and write locks. Not even a little. So this module only supports exclusive locks, periodt.
Which means β and this is the part you need to internalize, bestie β when you request a shared read lock, it is instead promoted to an exclusive write lock. You asked for a little lock, you got the full lock. No cap. π
π CONFIGURATION π
Okay so the module has to know how to connect to your MySQL database to acquire locks. There's no telepathy here, bestie. You must provide:
- a datasource name
- a user name
- a password
These options get passed in the usual Apache::Session style, and they're very similar to the options for Apache::Session::Store::MySQL. Sibling energy. π§
Example:
tie %hash, 'Apache::Session::MySQL', $id, {
LockDataSource => 'dbi:mysql:database',
LockUserName => 'database_user',
LockPassword => 'K00l'
};
Instead, you may pass in an already opened DBI handle to your database. Already got one? Slay, bring your own. π
tie %hash, 'Apache::Session::MySQL', $id, {
LockHandle => $dbh
};
π AUTHOR π
This module was written by Jeffrey William Baker <jwbaker@acm.org>. Iconic behavior, honestly. π
π¦ SEE ALSO π¦
- Apache::Session
That's a wrap, bestie! π This page is from the User Contributed Perl Documentation, it's perl v5.36.0, dated 2022-11-19, and yeah it's still filed under Apache...:MySQL(3pm). Go forth and lock responsibly. π«Άβ¨
π¦ where this page comes from
- debian bookworm: libapache-session-perl 1.94-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libapache-session-perl 1.94-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libapache-session-perl 1.94-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libapache-session-perl 1.94-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libapache-session-perl 1.94-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms