[Dancer-users] Using shared variables

Gurunandan Bhat gbhat at pobox.com
Tue Jan 24 20:52:48 CET 2012


Thanks David. I get it now. I did know the key fact that "...the process
which receives the second request is not necessarily the same one which
handled the first request..."

Thanks for explaining this clearly.

Regards
Gurunandan


On Wed, Jan 25, 2012 at 12:52 AM, David Precious <davidp at preshweb.co.uk>wrote:

> On Wed, 25 Jan 2012 00:37:12 +0530
> Gurunandan Bhat <gbhat at pobox.com> wrote:
>
> > Hi,
> >
> > I was wondering about the issues using a shared variable in a single
> > App.pm file. Here is what I mean:
> [...]
> > I first call Route1 then when I call Route 2, I expect that I will
> > have the modified value (by Route 1) of $var in route 2.
> > Unfortunately I get an undefined value for $var.
>
> That's a bad idea because, if you're running in anything other than
> standalone mode, the process which receives the second request is not
> necessarily the same one which handled the first request.
>
> You should use the 'vars' keyword if you need to share stuff between a
> single request, and use sessions (or e.g. memcached) to maintain state
> between requests.
>
> Even if you're only planning to run a standalone single-process app
> now, this design choice would likely bite you in the ass later, when
> you find you want to run under Starman or similar for performance.
>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120125/cb415f8d/attachment.htm>


More information about the Dancer-users mailing list