Mark Lawrence > NCGI > NCGI::Singleton

Download:
NCGI-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.12   Source  

NAME ^

NCGI::Singleton - Singleton object for persistent CGI environments

SYNOPSIS ^

  # In your package
  package MyPackage;
  use base 'NCGI::Singleton';

  # In scripts, other modules, wherever
  use MyPackage;
  my $obj = MyPackage->instance();

DESCRIPTION ^

NCGI::Singleton is an implementation of Class::Singleton that works in persistent Perl environments such as mod_perl and SpeedyCGI. It is drop-in-replaceable with Class::Singleton so nothing else is documented here.

The reason Class::Singleton doesn't work (as I would like it to) is because it relies on the existence of a global variable in a package. Since globals are not deleted for each CGI request it is not easy to have singletons that only exist for the length of a CGI request.

METHODS ^

instance

Returns the singleton, creating it if it doesn't already exist.

SEE ALSO ^

Class::Singleton

AUTHOR ^

Mark Lawrence <nomad@null.net>

COPYRIGHT AND LICENSE ^

Copyright (C) 2005-2007 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.