Catalyst::Plugin::CHI - CHI wrap of Catalyst
use Catalyst qw[CHI]; __PACKAGE__->config->{CHI} = { driver => 'File', cache_root => '/path/to/nowhere' }; my $data; unless ( $data = $c->cache->get('data') ) { $data = MyApp::Model::Data->retrieve('data'); $c->cache->set( 'data', $data ); } $c->response->body($data);
Mostly you need read the CHI. something like follows are accpetable.
__PACKAGE__->config->{CHI} = { driver => 'File', cache_root => '/path/to/nowhere' }; __PACKAGE__->config->{CHI} = { driver => 'FastMmap', root_dir => '/path/to/root', cache_size => '1k' }; __PACKAGE__->config->{CHI} = { driver => 'Memcached', servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ] }; __PACKAGE__->config->{CHI} = { driver => 'Multilevel', subcaches => [ { driver => 'Memory' }, { driver => 'Memcached', servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ] } ], };
the $c-cache> are the same as CHI.
$c-
Fayland Lam, <fayland at gmail.com>
<fayland at gmail.com>
Copyright 2008 Fayland Lam, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Plugin::CHI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::CHI
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::CHI
For more information on module installation, please visit the detailed CPAN module installation guide.