On 11/15/05, Leo Lapworth <[EMAIL PROTECTED]> wrote:
>
> On 15 Nov 2005, at 11:35, John Doe wrote:
> >>> Hope it's not a stupid question, but are you sure %d_cache
> >>> survives a
> >>> request? Maybe I'm totally misunderstanding something but I
> >>> thought after
> >>> the point
> >>>
> >>> } end lexical scope
> >>>
> >>> %d_cache gets destroyed (if not still referenced from somewhere
> >>> else).
> >>>
> >>> I would have left out the scope-{} to keep %d_cache at file level.
> >>> Would that be wrong? And why?
> >>
> >> The handler() sub stays in scope - it's basically a global variable,
> >> and it holds a reference to %d_cache. So %d_cache goes out of scope,
> >> but doesn't get destroyed. It hangs around until the next time
> >> handler() is called, at which point you're back in the same scope and
> >> can access %d_cache again.
>
> I don't think this would work...
>
> You can set up a global variable within your startup.pl (before apache
> spawns child processed) and all children will get it, but if you
> edit it in anyway the changes are only reflected in that specific child
> process and you have no way of knowing if the user will hit the
> same child process on their next page request.
>
> or have I missed something ?

Yes, but the fact that we're in a multi-process system is a slightly
different topic. The lexical will stick around between requests. But
each process will be accessing its own copy of the lexical variable.
So you should populate the lexical in the parent before forking, and
then never modify it again.

d.

Reply via email to