Apache...stgres(3pm)
π Apache::Session::Store::Postgres π
okay so bestie, you found the Apache...stgres(3pm) page, aka the manual for Apache::Session::Store::Postgres β a Perl module (a 3pm situation, for sure) that keeps your session data living rent-free in a Postgres database. let's get into it π«Ά
β¨ NAME β¨
Apache::Session::Store::Postgres β Store persistent data in a Postgres database πΎ
πΈ SYNOPSIS πΈ
the vibe check, in code:
use Apache::Session::Store::Postgres;
my $store = new Apache::Session::Store::Postgres;
$store->insert($ref);
$store->update($ref);
$store->materialize($ref);
$store->remove($ref);
like, that's literally it. four little methods and you're iconic β¨
π¦ DESCRIPTION π¦
Apache::Session::Store::Postgres fulfills the storage interface of Apache::Session. Session data is stored in a Postgres database.
periodt. that's the whole plot π
π SCHEMA π
To use this module, you will need at least these columns in a table called 'sessions', or another name if you supply the TableName parameter.
id char(32) # or however long your session IDs are.
a_session text # This has an ~8 KB limit :(
bestie. do you see that:(up there. that's not me being dramatic, that's the docs themselves being sad about the ~8 KB limit ona_session text. it's giving tiny storage. it's giving claustrophobic. π
To create this schema, you can execute this command using the psql program:
CREATE TABLE sessions (
id char(32) not null primary key,
a_session text
);
If you use some other command, ensure that there is a unique index on the table's id column. do not skip that part, fr fr π
π CONFIGURATION π
The module must know what datasource, username, and password to use when connecting to the database. These values can be set using the options hash (see Apache::Session documentation). The options are:
DataSourceUserNamePasswordHandleTableName
π Example π
tie %hash, 'Apache::Session::Postgres', $id, {
DataSource => 'dbi:Pg:dbname=database',
UserName => 'database_user',
Password => 'K00l'
};
Instead, you may pass in an already-opened DBI handle to your database.
tie %hash, 'Apache::Session::Postgres', $id, {
Handle => $dbh
};
so you either hand it the deets and let it connect itself, or you hand it a $dbh you already opened. main character energy either way, your choice π
β AUTHOR β
This modules was written by Jeffrey William Baker <jwbaker@acm.org>
A fix for the commit policy was contributed by Michael Schout <mschout@gkg.net>
shoutout to the legends who wrote it and to the one who fixed the commit policy π«Ά (yes the original says "This modules was written", we keep the facts exactly as they are, no cap)
π₯ SEE ALSO π₯
- Apache::Session
- Apache::Session::Store::DBI
go read those next, iykyk π
and that's the whole page, bestie!! this one shipped as part of perl v5.36.0, dated 2022-11-19, and the manual page title is the delightfully abbreviated Apache...stgres(3pm) π slay, you now know everything about storing session data in Postgres. go forth and CREATE TABLE. πβ¨π¦
π¦ 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