Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 10 additions & 8 deletions lib/Catalyst/Plugin/Session/Store/Redis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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/);

Expand All @@ -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) )
Expand All @@ -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)));
}

Expand All @@ -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;
Expand Down Expand Up @@ -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
)
);
};
Expand All @@ -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:
Expand Down