[Catalyst] Catalyst::Component/Model Instances and Attributes per
Request
Alejandro Imass
alejandro.imass at gmail.com
Thu Jul 15 20:37:59 GMT 2010
On Mon, Jul 12, 2010 at 3:08 PM, Tomas Doran <bobtfish at bobtfish.net> wrote:
>
[...]
> Each process is in a separate memory space if you're using FCGI or mod_perl
> or something, but it's not entirely certain (if you use
> Catalyst::Engine::PSGI and Corona (for example) then multiple requests can
> be in-flight and sharing the same logicial memory space application (they
> just have different instances of the request context).
>
So we can assume mod_worker would certainly mix this data. The initial
quetion wasn't so stupid after all ;-)
> However doing what you suggest above will work for FCGI/mod_perl (or
> generally anything forked), although it's a bit icky - the instance of your
> Model lasts forever, and so bashing some of the instance data in each
> request works..
>
Yes. I think for this particular case it's better for me to use a
class rather than an instance for this model. I'm suspecting that
instances are really to take advantage of caching DB connections and
things like that which I don't need or want for my particular model.
> I would however you return an entirely new instance constructed in
> ACCEPT_CONTEXT, or use Catalyst::Component::InstancePerContext if you'd like
> the instance you build to be scoped to the request.
>
Understood. But in that case it's better to use a class than an instance.
Thanks for your kind replies!
Alejandro Imass
More information about the Catalyst
mailing list