Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mason::plugin::cache(3pm) [debian man page]

Mason::Plugin::Cache(3pm)				User Contributed Perl Documentation				 Mason::Plugin::Cache(3pm)

NAME
Mason::Plugin::Cache - Provide component cache object and filter VERSION
version 0.04 SYNOPSIS
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 --> % }} DESCRIPTION
Adds a "cache" method and "Cache" filter to access a cache (CHI) object with a namespace unique to the component. INTERP PARAMETERS
cache_defaults 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. cache_root_class Class used to create a cache. Defaults to CHI. COMPONENT CLASS METHODS
cache 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. my $result = $.cache->get('key'); REQUEST METHODS
cache Same as calling "cache" on the current component class. This usage will be familiar to Mason 1 users. my $result = $m->cache->get('key'); FILTERS
Cache ($key, $options, [%cache_params]) Caches the content using "$self->cache" and the supplied cache $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 --> % }} SUPPORT
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 <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 SEE ALSO
Mason AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
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. perl v5.14.2 2011-06-24 Mason::Plugin::Cache(3pm)

Check Out this Related Man Page

HTML::Mason::Cache::BaseCache(3pm)			User Contributed Perl Documentation			HTML::Mason::Cache::BaseCache(3pm)

NAME
HTML::Mason::Cache::BaseCache - Base cache object DESCRIPTION
This is the base module for all cache implementations used in Mason. It provides a few additional methods on top of "Cache::BaseCache" in Dewitt Clinton's "Cache::Cache" package. An object of this class is returned from $m->cache. METHODS
clear () Remove all values in the cache. get (key, [%params]) Returns the value associated with key or undef if it is non-existent or expired. This is extended with the following optional name/value parameters: busy_lock => duration If the value has expired, set its expiration time to the current time plus duration (instead of removing it from the cache) before returning undef. This is used to prevent multiple processes from recomputing the same expensive value simultaneously. The duration may be of any form acceptable to set. expire_if => sub If the value exists and has not expired, call sub with the cache object as a single parameter. If sub returns a true value, expire the value. get_object (key) Returns the underlying "Cache::Object" object associated with key. The most useful methods on this object are $co->get_created_at(); # when was object stored in cache $co->get_accessed_at(); # when was object last accessed $co->get_expires_at(); # when does object expire expire (key) Expires the value associated with key, if it exists. Differs from remove only in that the cache object is left around, e.g. for retrieval by get_object. remove (key) Removes the cache object associated with key, if it exists. set (key, data, [duration]) Associates data with key in the cache. duration indicates the time until the value should be erased. If duration is unspecified, the value will never expire by time. $expires_in may be a simple number of seconds, or a string of the form "[number] [unit]", e.g., "10 minutes". The valid units are s, second, seconds, sec, m, minute, minutes, min, h, hour, hours, d, day, days, w, week, weeks, M, month, months, y, year, and years. perl v5.14.2 2012-02-04 HTML::Mason::Cache::BaseCache(3pm)
Man Page