File Coverage

blib/lib/Mojolicious/Plugin/Renderer/WithoutCache.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::Renderer::WithoutCache;
2 2     2   14341 use Mojo::Base 'Mojolicious::Plugin';
  2         6934  
  2         11  
3 2     2   1598 use Mojolicious::Plugin::Renderer::WithoutCache::Cache;
  2         3  
  2         19  
4              
5             =head1 NAME
6              
7             Mojolicious::Plugin::Renderer::WithoutCache - Disable the template cache in your Mojo app
8              
9             =begin html
10              
11            

12            
13             Coverage Status
14            

15              
16             =end html
17              
18             =head1 VERSION
19              
20             Version 0.04
21              
22             =cut
23              
24             our $VERSION = '0.04';
25             $VERSION = eval $VERSION;
26              
27             =head1 SYNOPSIS
28              
29             This plugin turns off the renderer's cache in L and L applications.
30              
31             use Mojolicious::Lite;
32             plugin 'Renderer::WithoutCache';
33              
34             =head1 DESCRIPTION
35              
36             This does what it says on the box. It turns off caching for the L
37             or any other renderer that's inside C<$app-Erenderer> by injecting a cache object that
38             does not do anything. This is supperior to setting the C of L
39             to C<0> if you plan to do a lot of uncached requests, becase L
40             will still try to cache, and every time L sets a value in the cache it
41             looks at the C, and then stops.
42              
43             Doing nothing at all is cheaper. But not a lot really.
44              
45             =head1 METHODS
46              
47             =head2 register
48              
49             Register the plugin in a L application.
50              
51             $plugin->register(Mojolicious->new);
52              
53             =cut
54              
55             sub register {
56 1     1 1 32 my ( $self, $app ) = @_;
57 1         4 $app->renderer->cache( Mojolicious::Plugin::Renderer::WithoutCache::Cache->new );
58             }
59              
60             =head1 AUTHOR
61              
62             simbabque, C<< >>
63              
64             =head1 BUGS
65              
66             Please report any bugs or feature requests through an issue
67             on github at L.
68              
69             =head1 SUPPORT
70              
71             You can find documentation for this module with the perldoc command.
72              
73             perldoc Mojolicious::Plugin::Renderer::WithoutCache
74              
75             =head2 Why would I want to turn off the cache?
76              
77             I don't know.
78              
79             =head1 ACKNOWLEDGEMENTS
80              
81             This plugin was inspired by Tom Hunt asking about turning the cache off
82             on L.
83              
84             =head1 LICENSE
85              
86             Copyright (C) simbabque.
87              
88             This library is free software; you can redistribute it and/or modify
89             it under the same terms as Perl itself.
90              
91             =cut
92              
93             1;
94