perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rolf Schaufelberger ...@plusw.de>
Subject Re: Singleton Persistence
Date Thu, 27 Feb 2014 17:34:30 GMT
Hi, 

we are using Class:Singleton , yet we manually destroy the singleton at the beginning of each
request before we create a new one. 
So I have a class PW::Application which isa Class::Singleton  and then 

    {
        no strict 'refs';
        ${"PW::Application\::_instance"}= undef;
    }
    $self->{appl}= PW::Application->instance($param{base});
 
I tried Apache::Singleton before, but, as far as I can remember,  it didn’t work with mp2.
So why are we using a singleton ? Well  , our app does not  only  consist of the web part
, we also have many scripts running that are part of the application, and we put things like
DBIx::Class schema object, config, current user etc in our singleton and so we can access
these data  the same way, neither if we run a function from web interface or from command
line.  
Since we don’t have heavy  load on our apps creating this singleton with every request works
for me .



Am 02.02.2014 um 02:14 schrieb John Dunlap <john@lariat.co>:

> In mod_perl, can instantiated singletons survive requests? I'm asking because I appear
to have one which *appears* to be bouncing back and forth between virtual hosts as perl interpreters
are recycled. Is this possible and, if yes, how do I prevent it?
> 
> Cheers!
> John


Rolf Schaufelberger

Mime
View raw message