That won't work - under Hypnotoad every worker would end up with it's
own copy, and while you would be able to update values inside a single
worker, it wouldn't work across the entire worker pool. Consider using
memcache or another key/value store that's convenient (redis, perhaps)
to store information like that, and fetch it when required.
On 10/21/2015 11:10 AM, Boris Baldassari wrote:
> Hiho dear Mojo folks,
>
> This is my first post here, so I'd like to start with a big thank you
> all for the work put on mojolicious. It just rocks. :-)
>
> I am building a full (not light) app which needs access to a set of
> variables (say config) stored in a dedicated module
> (MyApp::Model::Config). These values do change during the run, and I
> want all the workers to access the new values. This works very well in
> morbo, but as soon as I start using hypnotoad the values are not
> updated for all workers. As a consequence, depending on the worker
> serving your request you get either old or new values randomly.
>
> I started with a singleton helper put directly in the startup method:
> |
> $app->helper(repo =>sub{state $config =MyApp::Model::Config->new($app)});
> |
> This doesn't resolve the issue.
>
> Then I read about similar problems with db connection handles, and I
> decided to move them out of the startup method and I added some has
> attributes, still in the MyApp.pl class:
> |
> has my_config =>sub{state $config =MyApp::Model::Config->new($app);};
> |
> But it still doesn't work.
>
> So, how should I do that? Any advice on the design or code itself is
> welcome...
>
> Thanks in advance,
>
> --
> Boris
> --
> You received this message because you are subscribed to the Google
> Groups "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.