[Catalyst-commits] r13684 - in trunk/Catalyst-Plugin-PageCache: . lib/Catalyst/Plugin

timbunce at dev.catalyst.perl.org timbunce at dev.catalyst.perl.org
Wed Nov 3 11:10:34 GMT 2010


Author: timbunce
Date: 2010-11-03 11:10:34 +0000 (Wed, 03 Nov 2010)
New Revision: 13684

Modified:
   trunk/Catalyst-Plugin-PageCache/Changes
   trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm
Log:
Add app class name to index key to protect against caches that don't have a namespace set.
Add index key to config.
Document auto_check_user more clearly.


Modified: trunk/Catalyst-Plugin-PageCache/Changes
===================================================================
--- trunk/Catalyst-Plugin-PageCache/Changes	2010-11-01 23:31:59 UTC (rev 13683)
+++ trunk/Catalyst-Plugin-PageCache/Changes	2010-11-03 11:10:34 UTC (rev 13684)
@@ -1,6 +1,6 @@
 Revision history for Perl extension Catalyst::Plugin::PageCache
 
-0.23    2010-11-01 21:03
+0.30    2010-11-01 21:03  r13685
         - Updated tests to use Cache::FileCache instead of the deprecated ::FileCache.
           Report and patch by Rod Taylor, RT#53304 & RT#47373.
         - Fixed t/04critic.t to not fail if Test::Perl::Critic is not installed.
@@ -12,6 +12,7 @@
         - Refactored page cache storage logic, inspired by RT#53303.
         - Use SHA1 to create cache key to limit length and charset. RT#62343.
         - Treat the order of repeated URL parameter values as significant.
+        - Added app class name to index key for added safety.
 
 0.22    2009-06-25 10:38:00
         - Update to use MRO::Compat

Modified: trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm
===================================================================
--- trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm	2010-11-01 23:31:59 UTC (rev 13683)
+++ trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm	2010-11-03 11:10:34 UTC (rev 13684)
@@ -60,7 +60,7 @@
     
     my $cache = $c->cache; # curry the cache just once, here
 
-    my $index = $cache->get( "_page_cache_index" ) || {};
+    my $index = $cache->get( $config_PageCache->{index_page_key} ) || {};
 
     foreach my $key ( keys %{$index} ) {
         if ( $key =~ /^(?::[^:]+:)?$uri$/xms ) {
@@ -74,7 +74,7 @@
 
     if ( $removed ) {
         $cache->set(
-            "_page_cache_index",
+            $config_PageCache->{index_page_key},
             $index,
             $config_PageCache->{no_expire}
         );
@@ -160,9 +160,9 @@
             $cache->remove( $key );
 
             if ( !$config_PageCache->{disable_index} ) {
-                my $index = $cache->get( "_page_cache_index" ) || {};
+                my $index = $cache->get( $config_PageCache->{index_page_key} ) || {};
                 delete $index->{$key};
-                $cache->set( "_page_cache_index", $index,
+                $cache->set( $config_PageCache->{index_page_key}, $index,
                     $config_PageCache->{no_expire});
             }
         }
@@ -360,12 +360,10 @@
     if ( !$config_PageCache->{disable_index} ) {
         # Keep an index cache of all pages that have been cached, for use
         # with clear_cached_page
-        my $index = $cache->get( "_page_cache_index" ) || {};
+        my $index = $cache->get($config_PageCache->{index_page_key}) || {};
         $index->{$key} = 1;
-
-        # Save date in cache
-        $cache->set( "_page_cache_index", $index,
-            $config_PageCache->{no_expire});
+        # Save data in cache
+        $cache->set($config_PageCache->{index_page_key}, $index, $config_PageCache->{no_expire});
     }
 
     return $data;
@@ -392,6 +390,11 @@
     $config_PageCache->{busy_lock}        ||= 0;
     $config_PageCache->{debug}            ||= $c->debug;
 
+    # default the page key to include the app name to give some measure
+    # of protection if the cache doesn't have a namespace set.
+    $config_PageCache->{index_page_key} = "$c._page_cache_index"
+        unless defined $config_PageCache->{index_page_key};
+
     # detect the cache plugin being used and set appropriate
     # never-expires syntax
     if ( $c->can('cache') ) {
@@ -598,6 +601,11 @@
 enable this config option to avoid the overhead of creating and updating the
 cache index.  This option is disabled by default.
 
+    index_page_key => '...'
+
+The key string used for the index, Defaults to a string that includes the name
+of the Catalyst app class.
+
     busy_lock => 10
 
 On a high traffic site where page re-generation may take many seconds, a common
@@ -613,10 +621,13 @@
     debug => 1
 
 This will print additional debugging information to the Catalyst log.  You will
-need to have -Debug enabled to see these messages.  You can also specify an
-optional config parameter auto_check_user. If this option is enabled,
-automatic caching is disabled for logged in users.
+need to have -Debug enabled to see these messages.
 
+    auto_check_user => 1
+
+If this option is enabled, automatic caching is disabled for logged in users
+i.e., if the app class has a user_exists() method and it returns true.
+
     cache_hook => 'cache_hook_method'
     cache_finalize_hook => 'cache_finalize_hook_method'
     cache_dispatch_hook => 'cache_dispatch_hook_method'




More information about the Catalyst-commits mailing list