# man > Apache::Session::Lock::MySQL(3pm)

<think>The user wants me to transform a Perl module documentation into Open Knowledge Format (OKF) Markdown. Let me analyze the input:

1. It's a perldoc for `Apache::Session::Lock::MySQL`
2. I need to extract the technical content and reformat it
3. I need to start with YAML frontmatter
4. Follow the section structure specified

Let me create the output:

YAML frontmatter:
- type: CommandReference
- command: Apache::Session::Lock::MySQL
- mode: perldoc
- section: (empty, it's a Perl module)
- source: perldoc

Now for the sections:
- Quick Reference: extract common use cases
- Name: one-line description
- Synopsis: command syntax, condensed
- Options: grouped logically
- Examples: preserve if original has examples
- See Also: related commands
- Exit Codes: only if explicitly documented

Let me write this out:</think>

---
type: CommandReference
command: Apache::Session::Lock::MySQL
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `use Apache::Session::Lock::MySQL;` — load the locking module
- `$locker = Apache::Session::Lock::MySQL->new()` — create a locker instance
- `$locker->acquire_read_lock($ref)` — acquire shared lock (promoted to exclusive)
- `$locker->acquire_write_lock($ref)` — acquire exclusive lock
- `$locker->release_read_lock($ref)` — release shared lock
- `$locker->release_write_lock($ref)` — release exclusive lock
- `$locker->release_all_locks($ref)` — release all held locks
- `tie %hash, 'Apache::Session::MySQL', $id, { LockDataSource => ..., LockUserName => ..., LockPassword => ... }` — configure MySQL lock backend

## Name

`Apache::Session::Lock::MySQL` — provides mutual exclusion using MySQL

## Synopsis

perl
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](http://localhost/phpMan.php/perldoc/Apache%3A%3ASession/markdown). 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.

## Methods

- `new()` — construct a new locker instance
- `acquire_read_lock($ref)` — acquire a lock (promoted to exclusive since MySQL has no shared locks)
- `acquire_write_lock($ref)` — acquire an exclusive lock
- `release_read_lock($ref)` — release a previously acquired lock
- `release_write_lock($ref)` — release a previously acquired exclusive lock
- `release_all_locks($ref)` — release every lock held for this session

## Configuration

The module must know how to connect to your MySQL database to acquire locks. Provide a datasource name, user name, and password. Options follow the standard [Apache::Session](http://localhost/phpMan.php/perldoc/Apache%3A%3ASession/markdown) style, similar to [Apache::Session::Store::MySQL](http://localhost/phpMan.php/perldoc/Apache%3A%3ASession%3A%3AStore%3A%3AMySQL/markdown).

- `LockDataSource` — DBI datasource string (e.g. `dbi:mysql:database`)
- `LockUserName` — database user name
- `LockPassword` — database password
- `LockHandle` — pre-opened DBI handle to use instead of the datasource trio

## Examples

Connect using datasource, username, and password:

perl
tie %hash, 'Apache::Session::MySQL', $id, {
    LockDataSource => 'dbi:mysql:database',
    LockUserName   => 'database_user',
    LockPassword   => 'K00l'
};
Reuse an already opened DBI handle:

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

- [Apache::Session](http://localhost/phpMan.php/perldoc/Apache%3A%3ASession/markdown)
- [Apache::Session::Store::MySQL](http://localhost/phpMan.php/perldoc/Apache%3A%3ASession%3A%3AStore%3A%3AMySQL/markdown)

## Author

Jeffrey William Baker `<jwbaker@acm.org>`