I see I changed to use references:

$companyInfo = $m->cache->get('companyInfo', busy_lock => '30 seconds');

     if (!defined($companyInfo) || 0) {
                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});
     }

Thanks!

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

Reply via email to