[Catalyst] Store something in the stash at startup

will at serensoft.com will at serensoft.com
Tue Aug 17 13:59:28 GMT 2010


On Tue, Aug 17, 2010 at 6:23 AM, Tomas Doran <bobtfish at bobtfish.net> wrote:

>
> On 17 Aug 2010, at 06:27, Octavian Rasnita wrote:
>
>> I load and store this object in the stash on each request in the
>> Root::auto : Private method with:
>>
>> $c->stash(menu =3D> $c->model('Menu'));
>>
>> But this would re-create the menu object on each request, and this takes
>> time.
>>
>
> No, it wouldn't. The adaptor you showed has a lifetime of the application,
> and so it won't be recreated each request.
>

</lurk>
Hmm, this is interesting. Are you referring to the "Moose goodness" of

has "menu_data" =3D> (
   is =3D> "ro",
   isa =3D> "HashRef",
   default =3D> sub { shift->config->{menu_data} }, #pull data from config
);

Is that the part you're referring to as application-lifetime?


Also, even if you were creating an object every request (which you aren't),
> if you're worrying about this without numbers, then this is premature
> opimisation.
>
> Cheers
> t0m
>
>
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



-- =

will trillich
"I just try to make sure that the laziest thing I can do at any moment is
what I should be doing." -- matt.might.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100817/3e736=
8ea/attachment.htm


More information about the Catalyst mailing list