Data::...ver::Pg(3pm)

πŸ’– Data::Session::Driver::Pg πŸ’–

okay bestie, welcome to the Data::Session::Driver::Pg page β€” it's part of the User Contributed Perl Documentation crew, and it's basically the Postgres-era glow-up of your session storage. 🐘✨


🌸 NAME 🌸

Data::Session::Driver::Pg β€” it's a persistent session manager. that's the whole vibe. πŸ’…


✨ Synopsis ✨

ngl the synopsis is short and mysterious:

See Data::Session for details.

iconic of it, honestly. go read that one, bestie. 🫢


πŸ¦‹ Description πŸ¦‹

so here's the tea: Data::Session::Driver::Pg lets Data::Session manipulate sessions through DBD::Pg. that's it, that's the job, and it ate. πŸ”₯

to actually use this module you gotta do both of these things:

  • Specify a driver of type Pg, like Data::Session -> new(type => 'driver:Pg ...')
  • Specify a database handle like Data::Session -> new(dbh => $dbh) or a data source like Data::Session -> new(data_source => $string)

both. not one. both. periodt. πŸ‘‘


πŸŽ€ Case-sensitive Options πŸŽ€

for the important details, go check out "Case-sensitive Options" in Data::Session. don't skip it, it matters. πŸ’œ


πŸ’… Method: new() πŸ’…

creates a shiny new object of type Data::Session::Driver::Pg. main character energy fr. ✨

new() takes a hash of key/value pairs β€” some of which might be mandatory, and some combinations might be mandatory too. so like, read carefully, bestie. 😭

the keys are listed here in alphabetical order.

they're all lower-case because they're also method names, which means you can call them to set or get the value whenever you want. slay. πŸŽ€

  • data_col_name => $string β€” specifies the name of the column in the sessions table that holds the session data. this key is normally passed in as Data::Session -> new(data_col_name => $string). default is 'a_session'. this key is optional.
  • data_source => $string β€” specifies the data source (as used by DBI -> connect($data_source, $username, $password, $data_source_attr)) to obtain a database handle. this key is normally passed in as Data::Session -> new(data_source => $string). default is ''. this key is optional, as long as you supply a value for 'dbh'.
  • data_source_attr => $hashref β€” specifies the attributes (as used by DBI -> connect($data_source, $username, $password, $data_source_attr)) to obtain a database handle. this key is normally passed in as Data::Session -> new(data_source_attr => $hashref). default is {AutoCommit => 1, PrintError => 0, RaiseError => 1}. this key is optional.
  • dbh => $dbh β€” specifies the database handle to use to access the sessions table. this key is normally passed in as Data::Session -> new(dbh => $dbh). if you don't specify it, the module will use the values of these keys to get a database handle:
    • data_source
    • data_source_attr
    • username
    • password

default is ''. this key is optional.

  • host => $string β€” not used. πŸ’€
  • id_col_name => $string β€” specifies the name of the column in the sessions table that holds the session id. this key is normally passed in as Data::Session -> new(id_col_name => $string). default is 'id'. this key is optional.
  • password => $string β€” specifies the password (as used by DBI -> connect($data_source, $username, $password, $data_source_attr)) to obtain a database handle. this key is normally passed in as Data::Session -> new(password => $string). default is ''. this key is optional.
  • pg_bytea => $boolean β€” specifies (if pg_bytea => 1) that the a_session column in the sessions table is of type bytea. this key is normally passed in as Data::Session -> new(pg_bytea => $boolean). if both 'pg_bytea' and 'pg_text' are set to 1, 'pg_text' is forced to be 0. if both 'pg_bytea' and 'pg_text' are set to 0, 'pg_bytea' is forced to be 1. 🫠
  • pg_text => $boolean β€” specifies (if pg_text => 1) that the a_session column in the sessions table is of type text. this key is normally passed in as Data::Session -> new(pg_text => $boolean).
  • port => $string β€” not used. πŸ™ˆ
  • socket => $string β€” not used. πŸ’€
  • table_name => $string β€” specifies the name of the sessions table. this key is normally passed in as Data::Session -> new(table_name => $string). default is 'sessions'. this key is optional.
  • username => $string β€” specifies the username (as used by DBI -> connect($data_source, $username, $password, $data_source_attr)) to obtain a database handle. this key is normally passed in as Data::Session -> new(username => $string). default is ''. this key is optional.
  • verbose => $integer β€” prints more or less information to STDERR. this key is normally passed in as Data::Session -> new(verbose => $integer). typical values are 0, 1 and 2. this key is optional.

πŸ”₯ Method: remove($id) πŸ”₯

deletes the session identified by $id from storage β€” or dies if it can't. no in-between, no negotiating. 😀

returns 1. 🫢


⭐ Method: retrieve($id) ⭐

retrieves the session identified by $id from storage β€” or dies if it can't. same energy as above.

returns the session.

heads up bestie: this is a frozen session. you must thaw this value by calling the appropriate serialization driver's thaw() method. Data::Session calls the right thaw() automatically, so you're covered. πŸ’–

🌈 Method: store($id => $data) 🌈

writes the session identified by $id, together with its data $data, to storage β€” or dies if it can't. you know the drill. πŸ’…

$dbh -> selectall_arrayref is used, and the table is not locked. noted. πŸ‘€

returns 1. ✨


🧚 Method: traverse() 🧚

retrieves all ids from the sessions table, and for each id it calls the supplied subroutine with the id as the only parameter. one by one, bestie, very demure. πŸŽ€

returns 1. πŸ’œ


πŸ“ Support πŸ“

log a bug on RT: <https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Session>.


πŸ‘‘ Author πŸ‘‘

Data::Session was written by Ron Savage <ron@savage.net.au> in 2010.

home page: <http://savage.net.au/index.html>.


Australian copyright (c) 2010, Ron Savage.

All Programs of mine are 'OSI Certified Open Source Software';
you can redistribute them and/or modify them under the terms of
The Artistic License, a copy of which is available at:
http://www.opensource.org/licenses/index.html

and that's the whole page, bestie 🫢 this one came to you courtesy of perl v5.36.0 and it's dated 2023-02-14 β€” valentine's day, which is honestly so on brand for a page this cute πŸ’Œβœ¨πŸ’…

πŸ“¦ where this page comes from