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   13955 use Mojo::Base 'Mojolicious::Plugin';
  2         6976  
  2         14  
3 2     2   1635 use Mojolicious::Plugin::Renderer::WithoutCache::Cache;
  2         3  
  2         18  
4              
5             =head1 NAME
6              
7             Mojolicious::Plugin::Renderer::WithoutCache - Disable the template cache in your Mojo app
8              
9             =head1 VERSION
10              
11             Version 0.03
12              
13             =cut
14              
15             our $VERSION = '0.03';
16             $VERSION = eval $VERSION;
17              
18             =head1 SYNOPSIS
19              
20             This plugin turns off the renderer's cache in L and L applications.
21              
22             use Mojolicious::Lite;
23             plugin 'Renderer::WithoutCache';
24              
25             =head1 DESCRIPTION
26              
27             This does what it says on the box. It turns off caching for the L
28             or any other renderer that's inside C<$app-Erenderer> by injecting a cache object that
29             does not do anything. This is supperior to setting the C of L
30             to C<0> if you plan to do a lot of uncached requests, becase L
31             will still try to cache, and every time L sets a value in the cache it
32             looks at the C, and then stops.
33              
34             Doing nothing at all is cheaper. But not a lot really.
35              
36             =head1 METHODS
37              
38             =head2 register
39              
40             Register the plugin in a L application.
41              
42             $plugin->register(Mojolicious->new);
43              
44             =cut
45              
46             sub register {
47 1     1 1 30 my ( $self, $app ) = @_;
48 1         5 $app->renderer->cache( Mojolicious::Plugin::Renderer::WithoutCache::Cache->new );
49             }
50              
51             =head1 AUTHOR
52              
53             simbabque, C<< >>
54              
55             =head1 BUGS
56              
57             Please report any bugs or feature requests through an issue
58             on github at L.
59              
60             =head1 SUPPORT
61              
62             You can find documentation for this module with the perldoc command.
63              
64             perldoc Mojolicious::Plugin::Renderer::WithoutCache
65              
66             =head2 Why would I want to turn off the cache?
67              
68             I don't know.
69              
70             =head1 ACKNOWLEDGEMENTS
71              
72             This plugin was inspired by Tom Hunt asking about turning the cache off
73             on L.
74              
75             =head1 LICENSE AND COPYRIGHT
76              
77             Copyright 2017 simbabque.
78              
79             This program is free software; you can redistribute it and/or modify it
80             under the terms of the the Artistic License (2.0). You may obtain a
81             copy of the full license at:
82              
83             L
84              
85             Any use, modification, and distribution of the Standard or Modified
86             Versions is governed by this Artistic License. By using, modifying or
87             distributing the Package, you accept this license. Do not use, modify,
88             or distribute the Package, if you do not accept this license.
89              
90             If your Modified Version has been derived from a Modified Version made
91             by someone other than you, you are nevertheless required to ensure that
92             your Modified Version complies with the requirements of this license.
93              
94             This license does not grant you the right to use any trademark, service
95             mark, tradename, or logo of the Copyright Holder.
96              
97             This license includes the non-exclusive, worldwide, free-of-charge
98             patent license to make, have made, use, offer to sell, sell, import and
99             otherwise transfer the Package with respect to any patent claims
100             licensable by the Copyright Holder that are necessarily infringed by the
101             Package. If you institute patent litigation (including a cross-claim or
102             counterclaim) against any party alleging that the Package constitutes
103             direct or contributory patent infringement, then this Artistic License
104             to you shall terminate on the date that such litigation is filed.
105              
106             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
107             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
108             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
109             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
110             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
111             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
112             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
113             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
114              
115              
116             =cut
117              
118             1; # End of Mojolicious::Plugin::Renderer::WithoutCache