diff --git a/Changes b/Changes index 98c4a89..4728938 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,14 @@ Revision history for Catalyst-Plugin-Session-Store-Redis +0.06 March 8th, 2014 + - Fix disconnection Redis Server + - Add option configuration redis_reconnect + - Removed Catalyst log debug + +0.05 + +0.04 + 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..6c63fd1 100644 --- a/README +++ b/README @@ -13,7 +13,8 @@ SYNOPSIS MyApp->config->{session} = { expires => 3600, redis_server => '127.0.0.1:6379', - redis_debug => 0 # or 1! + redis_debug => 0, # or 1! + redis_reconnect => 60 # 60 is default }; # ... in an action: diff --git a/lib/Catalyst/Plugin/Session/Store/Redis.pm b/lib/Catalyst/Plugin/Session/Store/Redis.pm index 43c9b37..1d7829b 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.06'; __PACKAGE__->mk_classdata(qw/_session_redis_storage/); @@ -22,10 +22,10 @@ sub get_session_data { $c->_verify_redis_connection; if(my ($sid) = $key =~ /^expires:(.*)/) { - $c->log->debug("Getting expires key for $sid"); + $c->log->debug("Getting expires key for $sid") if $c->debug; return $c->_session_redis_storage->get($key); } else { - $c->log->debug("Getting $key"); + $c->log->debug("Getting $key") if $c->debug; my $data = $c->_session_redis_storage->get($key); if(defined($data)) { return thaw( decode_base64($data) ) @@ -41,10 +41,10 @@ sub store_session_data { $c->_verify_redis_connection; if(my ($sid) = $key =~ /^expires:(.*)/) { - $c->log->debug("Setting expires key for $sid: $data"); + $c->log->debug("Setting expires key for $sid: $data") if $c->debug; $c->_session_redis_storage->set($key, $data); } else { - $c->log->debug("Setting $key"); + $c->log->debug("Setting $key") if $c->debug; $c->_session_redis_storage->set($key, encode_base64(nfreeze($data))); } @@ -63,7 +63,7 @@ sub delete_session_data { $c->_verify_redis_connection; - $c->log->debug("Deleting: $key"); + $c->log->debug("Deleting: $key") if $c->debug; $c->_session_redis_storage->del($key); return; @@ -94,7 +94,8 @@ sub _verify_redis_connection { $c->_session_redis_storage( Redis->new( server => $cfg->{redis_server} || '127.0.0.1:6379', - debug => $cfg->{redis_debug} || 0 + debug => $cfg->{redis_debug} || 0, + reconnect => $cfg->{redis_reconnect} || 60 ) ); }; @@ -119,7 +120,8 @@ 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_reconnect => 60 # 60 is default }; # ... in an action: