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
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
5 changes: 4 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 14 additions & 6 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.04';

__PACKAGE__->mk_classdata(qw/_session_redis_storage/);

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