Apache...ngleton(3pm)

πŸ“¦
version 0.17 Β· 2 versions
  • 0.17 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.17 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Apache::Singleton β€” the Singleton class for mod_perl, bestie πŸ’–


🌸 VERSION 🌸

version 0.17 β€” yes she's an elder but she still slays πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

package Printer;
# default:
#   Request for mod_perl env
#   Process for non-mod_perl env
use base qw(Apache::Singleton);

package Printer::PerRequest;
use base qw(Apache::Singleton::Request);

package Printer::PerProcess;
use base qw(Apache::Singleton::Process);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so Apache::Singleton does the exact same thing as Class::Singleton, no cap β€” but she's got options when it comes to how long your object gets to live (that's the scope thing, iykyk). Go read Class::Singleton first, fr fr, she's the prequel πŸ’…


πŸ’œ OBJECT LIFETIME πŸ’œ

the way that you control this is by inheriting from one of the following subclasses of Apache::Singleton. that's it. that's the whole vibe check. choose your fighter πŸ‘‡

⭐ Request

use base qw(Apache::Singleton::Request);

one instance for one request, periodt. Apache::Singleton will remove the instance on each request β€” she's not clingy, she moves on 😌. this is implemented using the mod_perl pnotes API.

and listen: in a mod_perl environment (that means where $ENV{MOD_PERL} is defined, bestie), this is the default scope β€” so if you just inherit from Apache::Singleton, you get this same effect automatically. iconic behavior honestly.

⚠️ NOTE: you literally need PerlOptions +GlobalRequest in your apache configuration to use the Request lifetime method. no config, no vibes. don't skip this one πŸ™ˆ

🌈 Process

use base qw(Apache::Singleton::Process);

one instance for one httpd process 🫢. implemented using a package global β€” old school, but she works.

in a non-mod_perl environment, this is the default scope, and you may notice this is the same beaviour with Class::Singleton ;) (yes the typo "beaviour" is in the original, we keep the lore πŸ’€)

so basically: you can use this module safely under a non-mod_perl environment. safe. secure. slaying. βœ…


πŸ’– CREDITS πŸ’–

Original idea by Matt Sergeant <matt@sergeant.org> and Perrin Harkins <perrin@elem.com>. legends, honestly.

Initial implementation and versions 0.01 to 0.07 by Tatsuhiko Miyagawa <miyagawa@bulknews.net>. the founding mother πŸŽ€


πŸ‘‘ SEE ALSO πŸ‘‘

  • Apache::Singleton::Request
  • Apache::Singleton::Process
  • Class::Singleton

go read them, bestie, they're all part of the same cinematic universe πŸ“


🧚 SOURCE 🧚

the development version is on github at <https://github.com/mschout/apache-singleton> and may be cloned from <git://github.com/mschout/apache-singleton.git>

clone her. she's right there. waiting πŸ’…


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to bug-apache-singleton@rt.cpan.org or through the web interface at: http://rt.cpan.org/Public/Dist/Display.html?Name=Apache-Singleton

(we don't bite, we just fix things ✨)


🌸 AUTHOR 🌸

Michael Schout <mschout@cpan.org>


This software is copyright (c) 2009 by Michael Schout.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page, you're officially a Apache::Singleton scholar now, main character energy only πŸ‘‘ this was Apache::Singleton 0.17, perl v5.34.0, dated 2022-06-06 β€” love u, bye bestie πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from