Mojolicious::Plugin::Cache::Action - Action caching plugin
version 0.0015
Mojolicious:
$self->plugin('cache-action');
Mojolicious::Lite:
plugin 'cache-action';
This plugin caches responses of mojolicious applications. It works by caching the entire output of controller action for every request. Action caching internally uses the before_dispatch hook to serve the response from cache by skipping the entire controller body. Uncached responses are cached in an after_dispatch hook.
The cache is named according to the current host and path. So, the cache will differentiate between an identical page that is accessed from tucker.myplace.com/user/2 and from caboose.myplace.com/user/2 Different representation of the same resource such as tucker.myplace.com/book/list and tucker.myplace.com/book/list.json are considered as separate requests and so are cached separately.
This plugin uses CHI for caching responses. So, all the various cache backends and customization options of CHI are supported. By default, this plugin uses the Memory cache backend. Various other backends
File
FastMmap
Memcached
BerkleyDB
are also available through CHI.
actions => [qw/action1 action2 ....] #Mojolicious::Lite plugin cache-action => { actions => [qw/user show/]}; #Mojolicious $self->plugin('cache-action' => { actions => [qw/user show/]}); By default, all actions with successful GET requests will be cached
options => \%options All CHI module options are recognized #Mojolicious lite using memcache plugin cache-action => { options => { driver => 'Memcached', servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ] } } #Mojolicious lite using file based storage plugin cache-action => { options => { driver => 'File', root_dir => '/path/to/cache' } } #Mojolicious using file based storage $self->plugin('cache-action' => { options => { driver => 'File', root_dir => '/path/to/cache' } });
Siddhartha Basu <biosidd@gmail.com>
This software is copyright (c) 2010 by Siddhartha Basu.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Mojolicious::Plugin::Cache, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Cache
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Cache
For more information on module installation, please visit the detailed CPAN module installation guide.