# man > Apache::Session::Flex

---
type: CommandReference
command: Apache::Session::Flex
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `tie %hash, 'Apache::Session::Flex', $id, { Store => 'DB_File', Lock => 'Null', Generate => 'MD5', Serialize => 'Storable' };` — Berkeley DB storage, no locking, Storable serialization.
- `tie %hash, 'Apache::Session::Flex', $id, { Store => 'Postgres', Lock => 'Null', Generate => 'MD5', Serialize => 'Base64' };` — PostgreSQL storage, no locking, Base64 serialization.
- `tie %hash, 'Apache::Session::Flex', $id, { Store => 'MySQL', Lock => 'MySQL', Generate => 'MD5', Serialize => 'Storable' };` — MySQL storage with MySQL-based locking.
- `tie %hash, 'Apache::Session::Flex', $id, { Store => 'File', Lock => 'Semaphore', Generate => 'MD5', Serialize => 'Storable' };` — File storage with semaphore locking.

## Name
Apache::Session::Flex - Specify all session backend components at runtime

## Synopsis
perl
use Apache::Session::Flex;

tie %hash, 'Apache::Session::Flex', $id, {
    Store     => 'StoreModule',
    Lock      => 'LockModule',
    Generate  => 'GenerateModule',
    Serialize => 'SerializeModule'
};
## Arguments
All four components must be specified. Module names are auto‑prefixed with `Apache::Session::`; you give only the final part.

- `Store` — Backing store. Available: `DB_File`, `File`, `MySQL`, `Postgres`
- `Lock` — Locking scheme. Available: `Null`, `MySQL`, `Semaphore`
- `Generate` — ID generation. Available: `MD5`
- `Serialize` — Data serialization. Available: `Base64`, `Storable`, `UUEncode`

Pass additional arguments expected by your chosen `Store` and `Lock` modules as needed.

## Examples
perl
# Berkeley DB store with Storable serialization
tie %hash, 'Apache::Session::Flex', $id, {
    Store     => 'DB_File',
    Lock      => 'Null',
    Generate  => 'MD5',
    Serialize => 'Storable'
};

# PostgreSQL store with Base64 serialization
tie %hash, 'Apache::Session::Flex', $id, {
    Store     => 'Postgres',
    Lock      => 'Null',
    Generate  => 'MD5',
    Serialize => 'Base64'
};
## See Also
- [Apache::Session::File](https://metacpan.org/pod/Apache::Session::File)
- [Apache::Session::DB_File](https://metacpan.org/pod/Apache::Session::DB_File)
- [Apache::Session::MySQL](https://metacpan.org/pod/Apache::Session::MySQL)
- [Apache::Session::Postgres](https://metacpan.org/pod/Apache::Session::Postgres)
- [Apache::Session](https://metacpan.org/pod/Apache::Session)