Mason::Plugin::Cache - Provide component cache object and filter
version 0.03
my $result = $.cache->get('key'); if (!defined($result)) { ... compute $result ... $.cache->set('key', $result, '5 minutes'); } ... <% $.Cache('key2', '1 hour') { %> <!-- this will be cached for an hour --> </%>
Adds a cache method and Cache filter to access a cache (CHI) object with a namespace unique to the component.
cache
Cache
Hash of parameters passed to cache constructor. Defaults to
driver=>'File', root_dir => 'DATA_DIR/cache'
which will create a basic file cache under Mason's data directory.
Class used to create a cache. Defaults to CHI.
Returns a new cache object with the namespace set to the component's path. Parameters to this method, if any, are combined with cache_defaults and passed to the cache_root_class constructor. The cache object is memoized when no parameters are passed.
Caches the content using $self->cache and the supplied cache $key. $set_options, if provided, is passed as the third argument to $self->cache->set - it is usually an expiration time. %cache_params, if any, are passed to $self->cache.
$self->cache
$self->cache->set
<% $.Cache($my_key, '1 hour') { %> <!-- this will be cached for an hour --> </%>
The mailing list for Mason and Mason plugins is mason-users@lists.sourceforge.net. You must be subscribed to send a message. To subscribe, visit https://lists.sourceforge.net/lists/listinfo/mason-users.
You can also visit us at #mason on irc://irc.perl.org/#mason.
#mason
Bugs and feature requests will be tracked at RT:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mason-Plugin-Cache bug-mason-plugin-cache@rt.cpan.org
The latest source code can be browsed and fetched at:
http://github.com/jonswar/perl-mason-plugin-cache git clone git://github.com/jonswar/perl-mason-plugin-cache.git
Mason
Jonathan Swartz <swartz@pobox.com>
This software is copyright (c) 2011 by Jonathan Swartz.
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 Mason::Plugin::Cache, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mason::Plugin::Cache
CPAN shell
perl -MCPAN -e shell install Mason::Plugin::Cache
For more information on module installation, please visit the detailed CPAN module installation guide.