perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Perrin Harkins <>
Subject Re: Apache::Singleton (sharing one object)
Date Fri, 12 Aug 2005 14:24:44 GMT
On Fri, 2005-08-12 at 15:40 +0200, Tesfaiesus, Mesel wrote:
> I'm using the Aapache::Singleton Module and mod_perl 2.x/Apache2.x but I
> always seem to get a new Object as the properties are set to default
> every time.

It defaults to request scope, as described in the documentation.  To
make it switch to process scope, use this:

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

However, this will only persist in the one process (it's like putting
the object in a global).  If what you need is to make it available in
all processes, create it during startup and put it in a global.  If you
need that, but you need the data between processes to be in synch (e.g.
the counter in this example to be shared between all processes) you
should use a database or something like Cache::FastMmap to share the
state of it.

- Perrin

View raw message