info > Apache::Session::Lock::MySQL

πŸ“› NAME

Apache::Session::Lock::MySQL – Provides mutual exclusion using MySQL

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ”§ Create lock objectmy $locker = Apache::Session::Lock::MySQL->new()Instantiate a new lock object
πŸ”’ Acquire read lock (exclusive)$locker->acquire_read_lock($ref)Get an exclusive lock (read promoted to write)
πŸ”’ Acquire write lock$locker->acquire_write_lock($ref)Get an exclusive write lock
πŸ”“ Release read lock$locker->release_read_lock($ref)Release a previously acquired read lock
πŸ”“ Release write lock$locker->release_write_lock($ref)Release a previously acquired write lock
πŸ”“ Release all locks$locker->release_all_locks($ref)Release all session locks
βš™οΈ Configure via connection paramstie %hash, 'Apache::Session::MySQL', $id, { LockDataSource => 'dbi:mysql:database', LockUserName => 'user', LockPassword => 'pass' }Pass DSN, username, and password
βš™οΈ Configure via DBI handletie %hash, 'Apache::Session::MySQL', $id, { LockHandle => $dbh }Use an already‑opened database handle

πŸ“– 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);

πŸ”’ DESCRIPTION

Apache::Session::Lock::MySQL fulfills the locking interface of Apache::Session. πŸ” Mutual exclusion is achieved through the use of MySQL’s GET_LOCK and RELEASE_LOCK functions. MySQL does not support the notion of read and write locks, so this module only supports exclusive locks. ⚠️ When you request a shared read lock, it is instead promoted to an exclusive write lock.

βš™οΈ CONFIGURATION

The module must know how to connect to your MySQL database to acquire locks. You must provide a datasource name, a user name, and a password. These options are passed in the usual Apache::Session style, and are very similar to the options for Apache::Session::Store::MySQL. 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. πŸ”Œ

tie %hash, 'Apache::Session::MySQL', $id, {
    LockHandle => $dbh
};

πŸ‘€ AUTHOR

This module was written by Jeffrey William Baker <jwbaker AT acm.org>.

πŸ‘€ SEE ALSO

Apache::Session

πŸͺ perl v5.30.3 | 2020‑09‑20 | Apache::Session::Lock::MySQL(3pm)

Apache::Session::Lock::MySQL
πŸ“› NAME πŸš€ Quick Reference πŸ“– SYNOPSIS πŸ”’ DESCRIPTION βš™οΈ CONFIGURATION πŸ‘€ AUTHOR πŸ‘€ SEE ALSO

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-16 10:11 @2600:1f28:365:80b0:7cb9:fb:26c1:e368
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!