docs::a...ionUtil(3)

πŸ“¦ version 2.0.13, in nixos 26.05, nixpkgs unstable

πŸ¦‹ NAME πŸ¦‹

Apache2::ConnectionUtil β€” the Perl API for Apache connection utils, bestie. It's the little helper that gives you connection-record goodies. πŸ’…


✨ Synopsis ✨

okay so here's the whole vibe, literally copy this:

use Apache2::Connection     ();
use Apache2::ConnectionUtil ();
use Apache2::RequestRec     ();

# grab the connection object;
my $c = $r->connection;

# share perl objects like $r->pnotes
$old_val = $c->pnotes($key => $value);

That's it. That's the whole thing. You grab your connection object, and then you can share perl objects the same way $r->pnotes does it. Slay. πŸŽ€


🌸 Description 🌸

Apache2::ConnectionUtil provides the Apache connection record object utilities API. That's the assignment, and it ate. ✨


πŸ‘‘ API πŸ‘‘

Apache2::ConnectionUtil provides the following functions and/or methods (pnotes is the main character here, iykyk):

🫢 pnotes

Share Perl variables between requests over the lifetime of the connection. Not the request β€” the connection. This is the important part, don't forget it. πŸ”₯

$old_val  = $c->pnotes($key => $val);
$val      = $c->pnotes($key);
$hash_ref = $c->pnotes();
  • obj: $c ( an Apache2::Connection object ) β€” the invocant, your connection bestie.
  • opt arg1: $key ( string ) β€” a key value.
  • opt arg2: $val ( SCALAR ) β€” any scalar value (e.g. a reference to an array). Literally any scalar, no cap.
  • ret: (3 different possible values) β€” it's giving choose-your-own-adventure:
    • if both, $key and $val are passed, the previous value for $key is returned if such existed, otherwise undef is returned.
    • if only $key is passed, the current value for the given key is returned.
    • if no arguments are passed, a hash reference is returned, which can then be directly accessed without going through the pnotes() interface. 🧚
  • since: 2.0.3

See ("Apache2::RequestUtil::pnotes") for the details of the pnotes method usage. The usage is identical except for a few differences β€” and omg the differences matter:

  1. First is the use of $c instead of $r as the invocant. Different letter, different whole object. πŸ’€
  2. The second is that the data persists for the lifetime of the connection instead of the lifetime of the request. So if the connection is lost, so is the data stored in pnotes. Gone. Poof. 🫧
⚠️ fr fr read that again: connection goes bye-bye β†’ your pnotes data goes bye-bye too. Not a request-scoped thing, a connection-scoped thing. Vibe check your architecture accordingly. πŸ’…

🌈 See Also 🌈

  • Apache2::Connection.
  • Apache2::RequestUtil::pnotes.
  • mod_perl 2.0 documentation.

mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.


πŸ“ Authors πŸ“

The mod_perl development team and numerous contributors.


okay bestie that's the whole page, you're officially a connection-util expert now πŸ₯³ β€” this iconic little number was brought to you by perl v5.42.3, dated 2023-10-21, and filed under docs::a...ionUtil(3). periodt. πŸ’œ

πŸ“¦ where this page comes from