I think using cache is what I want. Thanks! However, now I see that it does not cache:
httpd.conf: PerlAddVar MasonAllowGlobals %companyInfo PerlAddVar MasonDataCacheApi chi PerlAddVar MasonDataCacheDefaults "driver => Memory" #PerlSetVar MasonCodeCacheMaxSize 0 #default is unlimited top autohandler: my $nocache=0; %companyInfo = $m->cache->get('companyInfo', busy_lock => '30 seconds'); if (!defined(%companyInfo) || $nocache) { my $compinf_o=$dbh->selectall_hashref(q{SELECT * FROM partnerInfo}, 'pGroup'); for my $key (keys %{$compinf_o}) {$companyInfo{$key}=JSON::XS->new- >utf8->decode($compinf_o->{$key}->{json} ) if $compinf_o->{$key}- >{json}; } $m->cache->set('companyInfo', %companyInfo, {expires_in => 3600}); } some other file: <%init> $m->out(JSON::XS->new->pretty(1)->encode(\% {$companyInfo{$session{_partnerGroup}}})); </%init> It displays if I set $nocache to 1, but then when I set it back I get empty data. My /var/spool/mason/SITE/cache is empty, but I think that's expected with 'driver => Memory'. On May 3, 2010, at 6:15 PM, Jonathan Swartz wrote: > You can use $m->cache, or > > <%once> > my %hash; > </%once> > > > On May 3, 2010, at 3:43 PM, Tech list wrote: > >> I want to have a fairly "static" hash that I load from a database and >> access globally. This hash rarely ever changes so I wanted to avoid >> hitting the database at every request. What are my best options for >> doing this? >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Mason-users mailing list >> Mason-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mason-users > ------------------------------------------------------------------------------ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users