M
max
I have a module that exists as a central data store, returning simple
scalars or references to larger structures. All of its data is stored
in a big hash, and I use AUTOLOAD to return the requested value.
The problem is that, with mod_perl, if the script that uses the module
changes the data (which with auto-vivication is pretty easy), the data
is changed for all subsequent scripts using that module run by that
particular apache child, which leads to the usual hair-pulling
intermittent bugs that mod_perl users historically puzzle over.
I've looked at a couple locking options, but the problem is that the
data can be arbitrarily deep references (which seems to rule out
Hash::Util). I might have MyModule->foo->{bar}{$baz}, and if $baz isn't
a valid key, it gets auto-vivified and there goes my weekend.
Is there a way I can prevent these changes from happening? And without
a huge performance penalty?
Thanks.
scalars or references to larger structures. All of its data is stored
in a big hash, and I use AUTOLOAD to return the requested value.
The problem is that, with mod_perl, if the script that uses the module
changes the data (which with auto-vivication is pretty easy), the data
is changed for all subsequent scripts using that module run by that
particular apache child, which leads to the usual hair-pulling
intermittent bugs that mod_perl users historically puzzle over.
I've looked at a couple locking options, but the problem is that the
data can be arbitrarily deep references (which seems to rule out
Hash::Util). I might have MyModule->foo->{bar}{$baz}, and if $baz isn't
a valid key, it gets auto-vivified and there goes my weekend.
Is there a way I can prevent these changes from happening? And without
a huge performance penalty?
Thanks.