Open autarch opened 3 years ago
From drolsky@cpan.org (@autarch) on 2014-07-09 18:00:27 :
On Wed Jul 09 09:46:10 2014, Bob.Gates@netapp.com wrote:
When a validation subroutine is called the first time, the parameter spec is prepared and cached to avoid unnecessary regeneration. It uses the fully qualified name of the subroutine (package + subname) as the cache key. In 99.999% of the use cases for this module, that will be the right thing to do.
Just a thought, but when using validated_list the default value is seems to be part of the parameter spec so anytime I use a computed default value, ie. my ($state,$timeout,$from) = validatedlist( \@, state =>{ optional=>1, default=>"true" }, timeout=>{ optional=>1, default=>60 }, from =>{ optional=>1, default=>$self->cluster-
select_nodes("up")->[0] }, ); I need to turn off caching else it only computes the default the first time the routine is entered and ever after the default does not change. This has caused me and the other members of my team to spend many hours of tracking down subtle bugs because of the caching. It might be nice to be able to globally turn off caching of validation specs since about 50% of our code uses computed defaults and the speed enhancement probably doesn't matter much to us.
This could probably work as an import option. It shouldn't really be global, just package-scoped.
Migrated from rt.cpan.org #97085 (status was 'open')
Requestors:
From bob.gates@netapp.com on 2014-07-09 13:46:10 :
When a validation subroutine is called the first time, the parameter spec is prepared and cached to avoid unnecessary regeneration. It uses the fully qualified name of the subroutine (package + subname) as the cache key. In 99.999% of the use cases for this module, that will be the right thing to do.
Just a thought, but when using validated_list the default value is seems to be part of the parameter spec so anytime I use a computed default value, ie. my ($state,$timeout,$from) = validatedlist( \@, state =>{ optional=>1, default=>"true" }, timeout=>{ optional=>1, default=>60 }, from =>{ optional=>1, default=>$self->cluster->select_nodes("up")->[0] }, ); I need to turn off caching else it only computes the default the first time the routine is entered and ever after the default does not change. This has caused me and the other members of my team to spend many hours of tracking down subtle bugs because of the caching. It might be nice to be able to globally turn off caching of validation specs since about 50% of our code uses computed defaults and the speed enhancement probably doesn't matter much to us.
thx