[dancer-users] Clarification on Dancer instances
cwallace at lodgingcompany.com
Thu Sep 1 23:25:48 BST 2016
On Thu, 1 Sep 2016 14:32:55 -0700
Amelia Ireland <aireland at lbl.gov> wrote:
> Do instances of a Dancer app stay around between requests, or is the
> app created when a request comes in, it does its stuff, and then it is
> destroyed? What happens to variables set with the 'var' keyword: will
> they persist on a dancer app between requests?
The worker processes persist until reloaded. Any global variables
(package globals or file-level "my" or "our" variables) will persist.
I take advantage of this in my webapps to pre-load names and other
commonly-used and rarely changing stuff at startup to reduce database
lookups in requests.
To refresh your variables, you could HUP the starman master with this
$ kill -HUP $(pgrep starman.master)
I'm *pretty sure* variables with "var" are not persistent, but are
only stored through the life cycle of a single request.
C. Chad Wallace, B.Sc.
The Lodging Company
OpenPGP Public Key ID: 0x262208A0
More information about the dancer-users