[Catalyst-commits] r9246 - in trunk/Catalyst-Plugin-Cache: .
lib/Catalyst/Plugin lib/Catalyst/Plugin/Cache/Choose
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sun Feb 8 07:37:56 GMT 2009
Author: t0m
Date: 2009-02-08 07:37:55 +0000 (Sun, 08 Feb 2009)
New Revision: 9246
Modified:
trunk/Catalyst-Plugin-Cache/Changes
trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm
trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache/Choose/KeyRegexes.pm
Log:
Change config key re RT#40344
Modified: trunk/Catalyst-Plugin-Cache/Changes
===================================================================
--- trunk/Catalyst-Plugin-Cache/Changes 2009-02-08 07:16:25 UTC (rev 9245)
+++ trunk/Catalyst-Plugin-Cache/Changes 2009-02-08 07:37:55 UTC (rev 9246)
@@ -1,5 +1,8 @@
-0.07 UNRELEASED
- - Switch from NEXT to MRO::Compat
+0.07
+ - Switch from NEXT to MRO::Compat.
+ - Change config key from 'cache' to 'Plugin::Cache', old key
+ is still supported for backwards compatibility, but the new
+ key is preferred (RT#40344).
0.06
- clarify the documentation on how to configure a backend
Modified: trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache/Choose/KeyRegexes.pm
===================================================================
--- trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache/Choose/KeyRegexes.pm 2009-02-08 07:16:25 UTC (rev 9245)
+++ trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache/Choose/KeyRegexes.pm 2009-02-08 07:37:55 UTC (rev 9246)
@@ -10,7 +10,7 @@
my $app = shift;
my $ret = $app->maybe::next::method( @_ );
- my $regexes = $app->config->{cache}{key_regexes} ||= [];
+ my $regexes = $app->_get_cache_plugin_config->{key_regexes} ||= [];
die "the regex list must be an array containing regexex/backend pairs" unless ref $regexes eq "ARRAY";
@@ -19,7 +19,7 @@
sub get_cache_key_regexes {
my ( $c, %meta ) = @_;
- @{ $c->config->{cache}{key_regexes} };
+ @{ $c->_get_cache_plugin_config->{key_regexes} };
}
sub choose_cache_backend {
Modified: trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm
===================================================================
--- trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm 2009-02-08 07:16:25 UTC (rev 9245)
+++ trunk/Catalyst-Plugin-Cache/lib/Catalyst/Plugin/Cache.pm 2009-02-08 07:37:55 UTC (rev 9246)
@@ -6,7 +6,7 @@
use strict;
use warnings;
-our $VERSION = "0.06";
+our $VERSION = "0.07";
use Scalar::Util ();
use Catalyst::Utils ();
@@ -32,14 +32,19 @@
$ret;
}
+sub _get_cache_plugin_config {
+ my ($app) = @_;
+ return $app->config->{'Plugin::Cache'} || $app->config->{cache};
+}
+
sub get_default_cache_backend_config {
my ( $app, $name ) = @_;
- $app->config->{cache}{backend} || $app->get_cache_backend_config("default");
+ $app->_get_cache_plugin_config->{backend} || $app->get_cache_backend_config("default");
}
sub get_cache_backend_config {
my ( $app, $name ) = @_;
- $app->config->{cache}{backends}{$name};
+ $app->_get_cache_plugin_config->{backends}{$name};
}
sub setup_cache_backends {
@@ -48,7 +53,9 @@
# give plugins a chance to find things for themselves
$app->maybe::next::method;
- foreach my $name ( keys %{ $app->config->{cache}{backends} } ) {
+ # FIXME - Don't know why the _get_cache_plugin_config method doesn't work here!
+ my $conf = $app->config->{'Plugin::Cache'} ? $app->config->{'Plugin::Cache'}->{backends} : $app->config->{cache}->{backends};
+ foreach my $name ( keys %$conf ) {
next if $app->get_cache_backend( $name );
$app->setup_generic_cache_backend( $name, $app->get_cache_backend_config( $name ) || {} );
}
@@ -71,7 +78,7 @@
sub default_cache_store {
my $app = shift;
- $app->config->{cache}{default_store} || $app->guess_default_cache_store;
+ $app->_get_cache_plugin_config->{default_store} || $app->guess_default_cache_store;
}
sub guess_default_cache_store {
@@ -149,7 +156,7 @@
sub curried_cache_class {
my ( $c, @meta ) = @_;
- $c->config->{cache}{curried_class} || "Catalyst::Plugin::Cache::Curried";
+ $c->_get_cache_plugin_config->{curried_class} || "Catalyst::Plugin::Cache::Curried";
}
sub curry_cache {
@@ -160,7 +167,7 @@
sub get_preset_curried {
my ( $c, $name ) = @_;
- if ( ref( my $preset = $c->config->{cache}{profiles}{$name} ) ) {
+ if ( ref( my $preset = $c->_get_cache_plugin_config->{profiles}{$name} ) ) {
return $preset if Scalar::Util::blessed($preset);
my @meta = ( ( ref $preset eq "HASH" ) ? %$preset : @$preset );
@@ -298,13 +305,13 @@
/;
# configure a backend or use a store plugin
- __PACKAGE__->config->{cache}{backend} = {
+ __PACKAGE__->config->{'Plugin::Cache'}{backend} = {
class => "Cache::Bounded",
# ... params for Cache::Bounded...
};
# typical example for Cache::Memcached::libmemcached
- __PACKAGE__->config->{cache}{backend} = {
+ __PACKAGE__->config->{'Plugin::Cache'}{backend} = {
class => "Cache::Memcached::libmemcached",
servers => ['127.0.0.1:11211'],
debug => 2,
@@ -494,12 +501,12 @@
=head1 CONFIGURATION
- $c->config->{cache} = {
+ $c->config->{'Plugin::Cache'} = {
...
};
All configuration parameters should be provided in a hash reference
-under the C<cache> key in the C<config> hash.
+under the C<Plugin::Cache> key in the C<config> hash.
=head2 Backend Configuration
@@ -515,13 +522,13 @@
Instantiate a backend from a L<Cache> compatible class. E.g.
- $c->config->{cache}{backends}{small_things} = {
+ $c->config->{'Plugin::Cache'}{backends}{small_things} = {
class => "Cache::Bounded",
interval => 1000,
size => 10000,
};
- $c->config->{cache}{backends}{large_things} = {
+ $c->config->{'Plugin::Cache'}{backends}{large_things} = {
class => "Cache::Memcached",
data => '1.2.3.4:1234',
};
@@ -534,7 +541,7 @@
Instantiate a backend using a store plugin, e.g.
- $c->config->{cache}{backend} = {
+ $c->config->{'Plugin::Cache'}{backend} = {
store => "FastMmap",
};
@@ -559,7 +566,7 @@
For example when you specify
- $c->config->{cache}{profiles}{thumbnails} = {
+ $c->config->{'Plugin::Cache'}{profiles}{thumbnails} = {
backend => "large_things",
};
More information about the Catalyst-commits
mailing list