[Catalyst] What can C::P::Cache cache?
Joe Landman
landman at scalableinformatics.com
Sat Jan 5 21:33:29 GMT 2008
Joe Landman wrote:
> Sounds like a strange question, but I want to know if I can put a
> complex data structure like a hash in there. Do I need to serialize it
> first?
>
> Alternatively, if it only handles scalars, that is also useful to know.
>
> Thanks.
Well ... never mind. I figured it out for my self. Short version, the
following appears to work nicely:
my $serialized_menu = $c->cache->get('menu');
if ($serialized_menu)
{
@menu = @{$serialized_menu};
$c->log->debug('Root::_get_navbar menu retrieved from cache');
}
else
{
$c->log->debug('Root::_get_navbar rebuilding menu');
# rebuild menu
$c->cache->set('menu',\@menu);
}
For some reason the manual's
unless ( ... ) {
} ...
construct did not work for this case.
--
Joe Landman
landman at scalableinformatics.com
More information about the Catalyst
mailing list