Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jonswar committed Feb 16, 2011
1 parent c37f5bc commit 5666b2d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 35 deletions.
7 changes: 3 additions & 4 deletions dist.ini
Expand Up @@ -24,17 +24,16 @@ repository.type = git
[MetaJSON]
[MetaYAML]
[MetaNoIndex]
directory = lib/Mason::Plugin::Cache/t
directory = lib/Mason::Plugin::Cache/Test
file = lib/Mason::Plugin::Cache/Util.pm
directory = lib/Mason/Plugin/Cache/t
[PkgVersion]
[PodWeaverIfPod]
[PruneCruft]

[Prereqs / RuntimeRequires]
CHI = 0

[Prereqs / TestRequires]
Test::More = 0
Test::Class::Most = 0

; These need to be at the bottom
[InstallGuide]
77 changes: 69 additions & 8 deletions lib/Mason/Plugin/Cache.pm
@@ -1,24 +1,85 @@
package Mason::Plugin::Cache;
use 5.008;
use strict;
use warnings;
use Moose;
with 'Mason::Plugin';

1;

# ABSTRACT: My great module
__END__
=pod
=head1 NAME
Mason::Plugin::Cache - Provide a cache object to each component
=head1 SYNOPSIS
use Mason::Plugin::Cache;
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 -->
</%>
=head1 DESCRIPTION
Mason::Plugin::Cache provides
Adds a C<cache> method and C<Cache> filter to access a cache (L<CHI|CHI>)
object with a namespace unique to the component.
=head1 INTERP PARAMETERS
=over
=item 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 L<data directory|data_dir>.
=item cache_root_class
Class used to create a cache. Defaults to L<CHI|CHI>.
=back
=head1 COMPONENT METHODS
=over
=item cache
Returns a new cache object with the namespace set to L<cache_namespace>.
Parameters to this method, if any, are combined with L<cache_defaults> and
passed to the L<cache_root_class> constructor. The cache object is memoized
when no parameters are passed.
=item cache_namespace
The cache namespace to use. Defaults to the component's
L<path|Mason::Component::ClassMeta/path>.
=back
=head1 FILTERS
=over
=item Cache ($key, $set_options, [%cache_params])
=head1 SEE ALSO
Caches the content using C<< $self->cache >> and the supplied cache I<$key>.
I<$set_options>, if provided, is passed as the third argument to C<<
$self->cache->set >> - it is usually an expiration time. I<%cache_params>, if
any, are passed to C<< $self->cache >>.
L<Some::Module>
<% $.Cache($my_key, '1 hour') { %>
<!-- this will be cached for an hour -->
</%>
=back
9 changes: 0 additions & 9 deletions lib/Mason/Plugin/Cache/Util.pm

This file was deleted.

14 changes: 0 additions & 14 deletions lib/Mason/Plugin/Cache/t/Sanity.pm

This file was deleted.

0 comments on commit 5666b2d

Please sign in to comment.