Jane Wilkie
Jane Wilkie

Reputation: 1743

Upgrading to Catalyst::Plugin::Cache from Catalyst::Plugin::Cache::FileCache

I am writing a build script to build a Catalyst app and apparently it's an older app since it uses Catalyst::Plugin::Cache::FileCache instead of the newer Catalyst::Plugin::Cache which supports a FileCache option. When doing a build through Makefile.PL I can't use cpanm because Catalyst::Plugin::Cache::FileCache is no longer retrievable. :-(

Finding the way to do that is what is proving problematic for me though.

I suppose I could make changes to the app to use Catalyst::Plugin::Cache but I'm not finding the documentation clear, or any easy way to do it.

Currently the app uses this....

__PACKAGE__->config( name => 'Stats', cache =>{storage=>'./tmp'} );

http://search.cpan.org/~mramberg/Catalyst-Plugin-Cache-FileCache-0.7/lib/Catalyst/Plugin/Cache/FileCache.pm is the documentation for the deprecated module.

The new documentation for Catalyst::Plugin::Cache is here..... http://metacpan.org/pod/Catalyst::Plugin::Cache

In one of my models, I have this....

__PACKAGE__->config(
                schema_class => 'Schema::STATS',
                connect_info => [
                                 'dbi:ODBC:DSN=....;driver=...;Server=...;database=...;RB_CONFIG=...;',
                                 'USER',
                                 'PASS',
                                 {limit_dialect=>'GenericSubQ',
                                  on_connect_do => ['set dateformat ymd'],
                                  cursor_class => 'DBIx::Class::Cursor::Cached'
                                 }
                                ],
               );


sub COMPONENT {
  my $self = shift->NEXT::COMPONENT(@_);
  $self->schema->default_resultset_attributes({ cache_object => Cache::FileCache->
       new({ namespace => 'Schema::STATS' }), cache_for=>3600});
  return $self;
}

I'm looking to make as few changes as possible right now to this app but is anyone aware of any easier way to make the couple of changes I need to switch to the newer Catalyst::Plugin::Cache?

Worse comes to worse I could always just package the older Catalyst::Plugin::Cache::FileCache source and install it but I was hoping there would just be an easier way to to use the new one.

Many thanks! Janie

Upvotes: 1

Views: 221

Answers (1)

hobbs
hobbs

Reputation: 240571

__PACKAGE__->config(
  'Plugin::Cache' => {
    backends => {
      default => {
        class => "Cache::FileCache",
        cache_root => "./tmp",
        namespace => "Pick Something",
    }
  }
);

and removing Plugin::Cache::FileCache and adding Plugin::Cache should get you about 90% of the way there. $c->cache will keep working as you expect, and it will be a vanilla Cache::FileCache object.

Upvotes: 2

Related Questions