Apache::Session::Lock::MySQL β Provides mutual exclusion using MySQL
| Use Case | Command | Description |
|---|---|---|
| π§ Create lock object | my $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 params | tie %hash, 'Apache::Session::MySQL', $id, { LockDataSource => 'dbi:mysql:database', LockUserName => 'user', LockPassword => 'pass' } | Pass DSN, username, and password |
| βοΈ Configure via DBI handle | tie %hash, 'Apache::Session::MySQL', $id, { LockHandle => $dbh } | Use an alreadyβopened database handle |
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);
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.
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
};
This module was written by Jeffrey William Baker <jwbaker AT acm.org>.
πͺ perl v5.30.3 | 2020β09β20 | Apache::Session::Lock::MySQL(3pm)
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/)