You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matt Sergeant <ma...@sergeant.org> on 2001/06/09 01:14:08 UTC

Re: Apache pnotes

On Sat, 9 Jun 2001, Jamie Krasnoo wrote:

> The Eagle Books explanation of notes isn't very clear. Could someone point
> me to a page that explains it somewhat better? In what situation would it be
> beneficial to use them?

You use notes (or pnotes) when you want a kind of global variable that is
localised to the request, but also accessible to sub-requests. For
example, Apache::Request stores it's current instance in pnotes, so that
it's guaranteed to be unique to that request. If it were stored in a
global, it would be the same apr object in subrequests.

Use pnotes instead of notes when you either need to store a perl object,
or need to store binary nulls.

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


Re: Apache pnotes

Posted by Perrin Harkins <pe...@elem.com>.
> You use notes (or pnotes) when you want a kind of global variable that is
> localised to the request, but also accessible to sub-requests.

It's also useful for caching things that MUST be cleaned up at the end of
the request.  You can put a database handle in pnotes and be confident that
it will get cleared at the end of the request, even if your code dies for
some reason.  It's safer than doing the same thing with a cleanup handler
that manually clears a global.

- Perrin