Mason::Plugin::Cache(3pm) | User Contributed Perl Documentation | Mason::Plugin::Cache(3pm) |
Mason::Plugin::Cache - Provide component cache object and filter
version 0.05
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.
driver=>'File', root_dir => 'DATA_DIR/cache'
which will create a basic file cache under Mason's data directory.
my $result = $.cache->get('key');
my $result = $m->cache->get('key');
$options is a scalar or hash reference. If a scalar, it is treated as the "expires_in" duration and passed as the third argument to "set". If it is a hash reference, it may contain name/value pairs for both "get" and "set".
%cache_params, if any, are passed to "$self->cache".
% $.Cache($my_key, '1 hour') {{ <!-- this will be cached for an hour --> % }} % $.Cache($my_key, { expire_if => sub { $.refresh } }, driver => 'RawMemory') {{ <!-- this will be cached until $.refresh is true --> % }}
If neither $key nor $options are passed, the key is set to 'Default' and the cache never expires.
% $.Cache() {{ <!-- cache this forever, or until explicitly removed --> % }}
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>.
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.
2022-05-27 | perl v5.34.0 |