Skip to content
Open
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
16 changes: 16 additions & 0 deletions lib/Catalyst/Plugin/Session/Store/Redis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ sub get_session_data {

$c->_verify_redis_connection;

$key = _apply_key_prefix($c, $key);

if(my ($sid) = $key =~ /^expires:(.*)/) {
$c->log->debug("Getting expires key for $sid");
return $c->_session_redis_storage->get($key);
Expand All @@ -39,6 +41,7 @@ sub store_session_data {
my ($c, $key, $data) = @_;

$c->_verify_redis_connection;
$key = _apply_key_prefix($c, $key);

if(my ($sid) = $key =~ /^expires:(.*)/) {
$c->log->debug("Setting expires key for $sid: $data");
Expand All @@ -61,6 +64,8 @@ sub store_session_data {
sub delete_session_data {
my ($c, $key) = @_;

$key = _apply_key_prefix($c, $key);

$c->_verify_redis_connection;

$c->log->debug("Deleting: $key");
Expand Down Expand Up @@ -100,6 +105,17 @@ sub _verify_redis_connection {
};
}

sub _apply_key_prefix {
my ($c, $key) = @_;

my $key_prefix = $c->_session_plugin_config->{key_prefix};
return $key if !$key_prefix;

my ($category, $session_id) = split(':', $key);
my @key = ($category, $key_prefix, $session_id);
return join(':', @key);
}

1;

__END__
Expand Down