djzort has asked for the wisdom of the Perl Monks concerning the following question:

friends,

I have a model which talks to a non-database source of data in my catalyst application. It is more or less a manual model which simply extends Catalyst::Model.

I would like to cache via Catalysts Cache plugin's, to hold various data as makes sense to me

Having loaded a cache plugin, the 'cache' method is available on the context object i.e. $c - however the $self object made available to the model's function doesnt seem to contain any methods for accessing the cache.

Having read through the relevant pod at http://search.cpan.org/~bobtfish/Catalyst-Plugin-Cache-0.12/lib/Catalyst/Plugin/Cache.pm it explains the controller usage, but doesnt mention if models can also use the cache

The DBIc model makes use of cache plugins, but it's example has proved to be unhelpful

Can someone lend me their insight?

  • Comment on Catalyst, Accessing Cache plugins from Models

Replies are listed 'Best First'.
Re: Catalyst, Accessing Cache plugins from Models
by Your Mother (Archbishop) on Mar 21, 2014 at 16:29 UTC
Re: Catalyst, Accessing Cache plugins from Models
by Anonymous Monk on Mar 21, 2014 at 07:57 UTC

    it explains the controller usage, but doesnt mention if models can also use the cache

    Well, the controller gets a cache ... the model doesn't get a cache ... give the model a reference to controller? Or use CHI?

    The DBIc model makes use of cache plugins, but it's example has proved to be unhelpful

    Where can I see that example?

      see also https://metacpan.org/pod/Catalyst::TraitFor::Model::DBIC::Schema::Caching