diff --git a/Changes b/Changes index 98c4a89..7450e88 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Catalyst-Plugin-Session-Store-Redis +0.04 April 20, 2016 + - Allow arbitrary configuration keys to be passed to Redis constructor + 0.03 December 12th, 2009 - Fix POD description - Fix logging typo (said 'Getting key' when it meant 'Setting key') diff --git a/README b/README index f0ef9c3..eda151d 100644 --- a/README +++ b/README @@ -13,7 +13,10 @@ SYNOPSIS MyApp->config->{session} = { expires => 3600, redis_server => '127.0.0.1:6379', - redis_debug => 0 # or 1! + redis_debug => 0, # or 1! + redis_password => 'password', + redis_reconnect => 60, + redis_every => 5000, }; # ... in an action: diff --git a/lib/Catalyst/Plugin/Session/Store/Redis.pm b/lib/Catalyst/Plugin/Session/Store/Redis.pm index 43c9b37..b122f59 100644 --- a/lib/Catalyst/Plugin/Session/Store/Redis.pm +++ b/lib/Catalyst/Plugin/Session/Store/Redis.pm @@ -12,7 +12,7 @@ use Redis; use Storable qw/nfreeze thaw/; use Try::Tiny; -our $VERSION = '0.03'; +our $VERSION = '0.04'; __PACKAGE__->mk_classdata(qw/_session_redis_storage/); @@ -91,11 +91,16 @@ sub _verify_redis_connection { try { $c->_session_redis_storage->ping; } catch { + my %redis_cfg; + while (my ($ck, $cv) = each %$cfg) { + next unless $ck =~ /^redis_(.+)/; + $redis_cfg{$1} = $cv; + } + + $redis_cfg{server} ||= '127.0.0.1:6379'; + $c->_session_redis_storage( - Redis->new( - server => $cfg->{redis_server} || '127.0.0.1:6379', - debug => $cfg->{redis_debug} || 0 - ) + Redis->new(%redis_cfg) ); }; } @@ -119,7 +124,10 @@ Catalyst::Plugin::Session::Store::Redis - Redis Session store for Catalyst MyApp->config->{Plugin::Session} = { expires => 3600, redis_server => '127.0.0.1:6379', - redis_debug => 0 # or 1! + redis_debug => 0, # or 1! + redis_password => 'password', + redis_reconnect => 60, + redis_every => 5000, }; # ... in an action: